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>
This commit is contained in:
Connor Abbott 2021-06-01 18:18:14 +02:00 committed by Marge Bot
parent 56dc84b95c
commit 9133999430

View file

@ -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);
}