nir/gcm: Rework the schedule late loop
This fixes a bug in code motion that occurred when the best block is the same as the schedule early block. In this case, because we're checking (lca != def->parent_instr->block) at the top of the loop, we never get to the check for loop depth so we wouldn't move it out of the loop. This commit reworks the loop to be a simple for loop up the dominator chain and we place the (lca != def->parent_instr->block) check at the end of the loop. Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
e9a4ec4bd8
commit
087e172179
|
@ -326,12 +326,13 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
|
||||||
* as far outside loops as we can get.
|
* as far outside loops as we can get.
|
||||||
*/
|
*/
|
||||||
nir_block *best = lca;
|
nir_block *best = lca;
|
||||||
while (lca != def->parent_instr->block) {
|
for (nir_block *block = lca; block != NULL; block = block->imm_dom) {
|
||||||
assert(lca);
|
if (state->blocks[block->index].loop_depth <
|
||||||
if (state->blocks[lca->index].loop_depth <
|
|
||||||
state->blocks[best->index].loop_depth)
|
state->blocks[best->index].loop_depth)
|
||||||
best = lca;
|
best = block;
|
||||||
lca = lca->imm_dom;
|
|
||||||
|
if (block == def->parent_instr->block)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
def->parent_instr->block = best;
|
def->parent_instr->block = best;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue