From 760c96628d8260e674cbff46a3404bb04ffe8752 Mon Sep 17 00:00:00 2001 From: Vladly <27299-vladly@users.noreply.gitlab.freedesktop.org> Date: Tue, 3 Jun 2025 14:50:37 +0000 Subject: [PATCH] ir3/legalize: don't allow end instruction as jump target on a5xx From experiments it appears that (jp) flag on "end" instruction has no effect (at least on a5xx). This means that we should insert "(jp)nop" before it, which is what blob is doing too. Part-of: --- src/freedreno/ir3/ir3_legalize.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/freedreno/ir3/ir3_legalize.c b/src/freedreno/ir3/ir3_legalize.c index 98c6bc2f154..9965031cf51 100644 --- a/src/freedreno/ir3/ir3_legalize.c +++ b/src/freedreno/ir3/ir3_legalize.c @@ -1171,6 +1171,15 @@ mark_jp(struct ir3_block *block) struct ir3_instruction *target = list_first_entry(&block->instr_list, struct ir3_instruction, node); + + /* Add nop instruction for (jp) flag since it has no effect on a5xx when set + * on the end instruction. + */ + if (target->opc == OPC_END && block->shader->compiler->gen == 5) { + struct ir3_builder build = ir3_builder_at(ir3_before_instr(target)); + target = ir3_NOP(&build); + } + target->flags |= IR3_INSTR_JP; }