From: Rhys Perry Date: Fri, 22 May 2020 14:42:12 +0000 (+0100) Subject: aco: fix interaction with 3f branch workaround and p_constaddr X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8aa98cebc15e6f6f8bcf42162399b5826376b3dc;p=mesa.git aco: fix interaction with 3f branch workaround and p_constaddr The offset was incorrect if we inserted a nop before the p_constaddr. Signed-off-by: Rhys Perry Fixes: 93c8ebfa ('aco: Initial commit of independent AMD compiler') Part-of: --- diff --git a/src/amd/compiler/aco_assembler.cpp b/src/amd/compiler/aco_assembler.cpp index 8876b5bc8f8..3bdea63201d 100644 --- a/src/amd/compiler/aco_assembler.cpp +++ b/src/amd/compiler/aco_assembler.cpp @@ -42,8 +42,6 @@ static uint32_t get_sdwa_sel(unsigned sel, PhysReg reg) void emit_instruction(asm_context& ctx, std::vector& out, Instruction* instr) { - uint32_t instr_offset = out.size() * 4u; - /* lower remaining pseudo-instructions */ if (instr->opcode == aco_opcode::p_constaddr) { unsigned dest = instr->definitions[0].physReg(); @@ -68,7 +66,7 @@ void emit_instruction(asm_context& ctx, std::vector& out, Instruction* encoding |= 255 << 8; out.push_back(encoding); ctx.constaddrs.push_back(out.size()); - out.push_back(-(instr_offset + 4) + offset); + out.push_back(offset); /* s_addc_u32 dest[1], dest[1], 0 */ encoding = (0b10 << 30); @@ -797,7 +795,7 @@ void fix_branches(asm_context& ctx, std::vector& out) void fix_constaddrs(asm_context& ctx, std::vector& out) { for (unsigned addr : ctx.constaddrs) - out[addr] += out.size() * 4u; + out[addr] += (out.size() - addr + 1u) * 4u; } unsigned emit_program(Program* program,