Mesa (main): ir3/sched: Speed up live_effect

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 28 16:49:08 UTC 2021


Module: Mesa
Branch: main
Commit: 9133999430e67b7bae6788d0a8c03d9dc1074bdc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9133999430e67b7bae6788d0a8c03d9dc1074bdc

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Tue Jun  1 18:18:14 2021 +0200

ir3/sched: Speed up live_effect

If we've identified another use that isn't scheduled yet, we can break
right away rather than iterating through all the other uses. While this
could be optimized further, this simple change makes
dEQP-VK.subgroups.ballot_broadcast.compute.subgroupbroadcast_ivec4 go
from 40 seconds to 1.9 seconds on a release build according to my
unscientific testing.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11613>

---

 src/freedreno/ir3/ir3_sched.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/freedreno/ir3/ir3_sched.c b/src/freedreno/ir3/ir3_sched.c
index 7900af15a62..69281d37692 100644
--- a/src/freedreno/ir3/ir3_sched.c
+++ b/src/freedreno/ir3/ir3_sched.c
@@ -486,14 +486,15 @@ nearest_use(struct ir3_instruction *instr)
 	return nearest;
 }
 
-static int
-use_count(struct ir3_instruction *instr)
+static bool
+is_only_nonscheduled_use(struct ir3_instruction *instr, struct ir3_instruction *use)
 {
-	unsigned cnt = 0;
-	foreach_ssa_use (use, instr)
-		if (!is_scheduled(use))
-			cnt++;
-	return cnt;
+	foreach_ssa_use (other_use, instr) {
+		if (other_use != use && !is_scheduled(other_use))
+			return false;
+	}
+
+	return true;
 }
 
 /* find net change to live values if instruction were scheduled: */
@@ -517,7 +518,7 @@ live_effect(struct ir3_instruction *instr)
 		if (instr->block != src->block)
 			continue;
 
-		if (use_count(src) == 1)
+		if (is_only_nonscheduled_use(src, instr))
 			freed_live += dest_regs(src);
 	}
 



More information about the mesa-commit mailing list