From 39ff20b7573899569c9e6b19ae14819de71a0e21 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Fri, 4 Jul 2025 11:17:52 +0200 Subject: [PATCH] ir3/legalize: emit predication quirk nops in next block Emitting in the same block as the pred[tfe] caused helper_sched to sometimes insert unnecessary (eq). For example: block i: ... prede (eq)(rpt6)nop block i+1: (eq)nop Emitting the quirk nops in the next block (i+1 in this case) prevents this. Note that the small number of shaders where NOPs regress, are cases where an extra (eq)nop is inserted in a block that doesn't contain any other nops (but did contain the quirk nop before this change). Totals from 3814 (2.32% of 164575) affected shaders: Instrs: 6732543 -> 6732252 (-0.00%); split: -0.01%, +0.00% CodeSize: 11978286 -> 11978086 (-0.00%); split: -0.00%, +0.00% NOPs: 1683239 -> 1682948 (-0.02%); split: -0.02%, +0.01% (ss)-stall: 635237 -> 634077 (-0.18%) (sy)-stall: 2562027 -> 2533761 (-1.10%); split: -1.10%, +0.00% Cat0: 1849898 -> 1849607 (-0.02%); split: -0.02%, +0.01% Signed-off-by: Job Noorman Part-of: --- src/freedreno/ir3/ir3_legalize.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/freedreno/ir3/ir3_legalize.c b/src/freedreno/ir3/ir3_legalize.c index 757a579c01c..183877c295f 100644 --- a/src/freedreno/ir3/ir3_legalize.c +++ b/src/freedreno/ir3/ir3_legalize.c @@ -1319,17 +1319,17 @@ add_predication_workaround(struct ir3_compiler *compiler, struct ir3_instruction *prede) { if (predtf && compiler->predtf_nop_quirk) { - struct ir3_builder build = ir3_builder_at(ir3_after_block(predtf->block)); + struct ir3_builder build = ir3_builder_at( + ir3_before_block(predtf->block->predecessors[0]->successors[1])); struct ir3_instruction *nop = ir3_NOP(&build); nop->repeat = 4; - ir3_instr_move_after(nop, predtf); } if (compiler->prede_nop_quirk) { - struct ir3_builder build = ir3_builder_at(ir3_after_block(prede->block)); + struct ir3_builder build = + ir3_builder_at(ir3_before_block(prede->block->successors[0])); struct ir3_instruction *nop = ir3_NOP(&build); nop->repeat = 6; - ir3_instr_move_after(nop, prede); } }