From d169dad3937e2b2692c3992e0ed417849e971ee6 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 8 Jun 2021 18:06:46 +0200 Subject: [PATCH] aco: fix emitting literal offsets with SMEM on GFX7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the offset is negative, reg() isn't 255. Fix this by splitting SGPR and literal emission. While we are at it, adjust a comment saying that literals are also accepted on GFX6 which is wrong. Fixes another batch of robustness tests. Cc: 21.1 mesa-stable Signed-off-by: Samuel Pitoiset Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_assembler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/amd/compiler/aco_assembler.cpp b/src/amd/compiler/aco_assembler.cpp index ce42f59a659..fa664f95553 100644 --- a/src/amd/compiler/aco_assembler.cpp +++ b/src/amd/compiler/aco_assembler.cpp @@ -173,15 +173,17 @@ void emit_instruction(asm_context& ctx, std::vector& out, Instruction* encoding |= instr->definitions.size() ? instr->definitions[0].physReg() << 15 : 0; encoding |= instr->operands.size() ? (instr->operands[0].physReg() >> 1) << 9 : 0; if (instr->operands.size() >= 2) { - if (!instr->operands[1].isConstant() || instr->operands[1].constantValue() >= 1024) { + if (!instr->operands[1].isConstant()) { encoding |= instr->operands[1].physReg().reg(); + } else if (instr->operands[1].constantValue() >= 1024) { + encoding |= 255; /* SQ_SRC_LITERAL */ } else { encoding |= instr->operands[1].constantValue() >> 2; encoding |= 1 << 8; } } out.push_back(encoding); - /* SMRD instructions can take a literal on GFX6 & GFX7 */ + /* SMRD instructions can take a literal on GFX7 */ if (instr->operands.size() >= 2 && instr->operands[1].isConstant() && instr->operands[1].constantValue() >= 1024) out.push_back(instr->operands[1].constantValue() >> 2); return;