aco/insert_delay_alu: handle loop latch block before loop body

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39519>
This commit is contained in:
Daniel Schürmann 2026-02-02 13:40:24 +01:00 committed by Marge Bot
parent 102aca9843
commit ade5e300ab

View file

@ -307,6 +307,28 @@ handle_block(Program* program, Block& block, delay_ctx& ctx)
block.instructions.swap(new_instructions);
}
void
handle_loop_latch(Program* program, Block& block, delay_ctx& ctx)
{
/* No actual loop. */
if (block.linear_preds.size() == 1)
return;
/* The loop header is also the loop latch. */
if (block.kind & block_kind_loop_latch)
return;
unsigned i = block.index;
while (ctx.program->blocks[i].loop_nest_depth >= block.loop_nest_depth) {
Block& latch_block = ctx.program->blocks[i++];
if (latch_block.loop_nest_depth == block.loop_nest_depth &&
(latch_block.kind & block_kind_loop_latch)) {
handle_block(program, latch_block, ctx);
break;
}
}
}
} /* end namespace */
void
@ -321,6 +343,12 @@ insert_delay_alu(Program* program)
if (current.instructions.empty())
continue;
/* Handle the loop latch block before the loop body. */
if (current.kind & block_kind_loop_header)
handle_loop_latch(program, current, ctx);
else if (current.kind & block_kind_loop_latch)
continue;
handle_block(program, current, ctx);
/* Reset ctx if there is a jump, assuming ALU will be done