aco: fix p_constaddr with a non-zero offset

Seems this broke a while ago and we never noticed.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Fixes: 0af7ff49fd ("aco: lower p_constaddr into separate instructions earlier")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16460>
(cherry picked from commit bd8f8dda8c)
This commit is contained in:
Rhys Perry 2022-05-11 19:23:00 +01:00 committed by Dylan Baker
parent 7f15a224fa
commit 982ea480dc
4 changed files with 7 additions and 5 deletions

View file

@ -60,7 +60,7 @@
"description": "aco: fix p_constaddr with a non-zero offset",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"because_sha": "0af7ff49fdecd05531b4c4f5fb841e11f9f451c1"
},
{

View file

@ -82,10 +82,12 @@ emit_instruction(asm_context& ctx, std::vector<uint32_t>& out, Instruction* inst
instr->opcode = aco_opcode::s_getpc_b64;
instr->operands.pop_back();
} else if (instr->opcode == aco_opcode::p_constaddr_addlo) {
ctx.constaddrs[instr->operands[1].constantValue()].add_literal = out.size() + 1;
ctx.constaddrs[instr->operands[2].constantValue()].add_literal = out.size() + 1;
instr->opcode = aco_opcode::s_add_u32;
instr->operands[1] = Operand::zero();
instr->operands.pop_back();
assert(instr->operands[1].isConstant());
/* in case it's an inline constant, make it a literal */
instr->operands[1].setFixed(PhysReg(255));
}

View file

@ -2100,7 +2100,7 @@ lower_to_hw_instr(Program* program)
PhysReg reg = instr->definitions[0].physReg();
bld.sop1(aco_opcode::p_constaddr_getpc, instr->definitions[0], Operand::c32(id));
bld.sop2(aco_opcode::p_constaddr_addlo, Definition(reg, s1), bld.def(s1, scc),
Operand(reg, s1), Operand::c32(id));
Operand(reg, s1), instr->operands[0], Operand::c32(id));
bld.sop2(aco_opcode::s_addc_u32, Definition(reg.advance(4), s1), bld.def(s1, scc),
Operand(reg.advance(4), s1), Operand::zero(), Operand(scc, s1));
break;

View file

@ -222,7 +222,7 @@ BEGIN_TEST(assembler.long_jump.constaddr)
//! s_add_u32 s0, s0, 0xe0 ; 8000ff00 000000e0
bld.sop1(aco_opcode::p_constaddr_getpc, Definition(PhysReg(0), s2), Operand::zero());
bld.sop2(aco_opcode::p_constaddr_addlo, Definition(PhysReg(0), s1), bld.def(s1, scc),
Operand(PhysReg(0), s1), Operand::zero());
Operand(PhysReg(0), s1), Operand::zero(), Operand::zero());
program->blocks[2].linear_preds.push_back(0u);
program->blocks[2].linear_preds.push_back(1u);