summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFilip Gawin <filip.gawin@zoho.com>2021-10-06 16:50:21 +0200
committerMarge Bot <emma+marge@anholt.net>2022-02-02 16:50:03 +0000
commit9322b76fc498febf6f99849723a5c48fb38817ef (patch)
tree556a811a5c04bf3949558a453e1f46379660e3a8 /src
parentf724f95542b2f7029608e9689a6d8cd386b5b42c (diff)
r300: replace recursive calls with loops
Recursive "loops" tend to be more difficult to follow and understand. Additionally iterative approach should be nicer for compiler. (Less to allocate on stack and easier to optimize) Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13226>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/r300/compiler/radeon_pair_schedule.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c b/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c
index 9e008149e57..1c8130cdf35 100644
--- a/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c
+++ b/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c
@@ -367,45 +367,41 @@ static void calc_score_readers(struct schedule_instruction * sinst)
*/
static void commit_update_reads(struct schedule_state * s,
struct schedule_instruction * sinst){
- unsigned int i;
- for(i = 0; i < sinst->NumReadValues; ++i) {
- struct reg_value * v = sinst->ReadValues[i];
- assert(v->NumReaders > 0);
- v->NumReaders--;
- if (!v->NumReaders) {
- if (v->Next) {
- decrease_dependencies(s, v->Next->Writer);
+ do {
+ for(unsigned int i = 0; i < sinst->NumReadValues; ++i) {
+ struct reg_value * v = sinst->ReadValues[i];
+ assert(v->NumReaders > 0);
+ v->NumReaders--;
+ if (!v->NumReaders) {
+ if (v->Next) {
+ decrease_dependencies(s, v->Next->Writer);
+ }
}
}
- }
- if (sinst->PairedInst) {
- commit_update_reads(s, sinst->PairedInst);
- }
+ } while ((sinst = sinst->PairedInst));
}
static void commit_update_writes(struct schedule_state * s,
struct schedule_instruction * sinst){
- unsigned int i;
- for(i = 0; i < sinst->NumWriteValues; ++i) {
- struct reg_value * v = sinst->WriteValues[i];
- if (v->NumReaders) {
- for(struct reg_value_reader * r = v->Readers; r; r = r->Next) {
- decrease_dependencies(s, r->Reader);
+ do {
+ for(unsigned int i = 0; i < sinst->NumWriteValues; ++i) {
+ struct reg_value * v = sinst->WriteValues[i];
+ if (v->NumReaders) {
+ for(struct reg_value_reader * r = v->Readers; r; r = r->Next) {
+ decrease_dependencies(s, r->Reader);
+ }
+ } else {
+ /* This happens in instruction sequences of the type
+ * OP r.x, ...;
+ * OP r.x, r.x, ...;
+ * See also the subtlety in how instructions that both
+ * read and write the same register are scanned.
+ */
+ if (v->Next)
+ decrease_dependencies(s, v->Next->Writer);
}
- } else {
- /* This happens in instruction sequences of the type
- * OP r.x, ...;
- * OP r.x, r.x, ...;
- * See also the subtlety in how instructions that both
- * read and write the same register are scanned.
- */
- if (v->Next)
- decrease_dependencies(s, v->Next->Writer);
}
- }
- if (sinst->PairedInst) {
- commit_update_writes(s, sinst->PairedInst);
- }
+ } while ((sinst = sinst->PairedInst));
}
static void notify_sem_wait(struct schedule_state *s)