From 68abc0731715b2ec3048d0944250b96a5302b4bc Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 15 Jan 2020 13:08:17 +0100 Subject: [PATCH] aco: fix emitting SMEM instructions with no operands on GFX6-GFX7 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Like s_memtime. Fixes dEQP-VK.glsl.shader_clock.* on GFX6. Signed-off-by: Samuel Pitoiset Reviewed-by: Daniel Schürmann Tested-by: Marge Bot Part-of: --- src/amd/compiler/aco_assembler.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/amd/compiler/aco_assembler.cpp b/src/amd/compiler/aco_assembler.cpp index 69b8a9b33c6..a9dd6b441e2 100644 --- a/src/amd/compiler/aco_assembler.cpp +++ b/src/amd/compiler/aco_assembler.cpp @@ -154,15 +154,17 @@ void emit_instruction(asm_context& ctx, std::vector& out, Instruction* encoding |= opcode << 22; encoding |= instr->definitions.size() ? instr->definitions[0].physReg() << 15 : 0; encoding |= instr->operands.size() ? (instr->operands[0].physReg() >> 1) << 9 : 0; - if (!instr->operands[1].isConstant() || instr->operands[1].constantValue() >= 1024) { - encoding |= instr->operands[1].physReg().reg; - } else { - encoding |= instr->operands[1].constantValue() >> 2; - encoding |= 1 << 8; + if (instr->operands.size() >= 2) { + if (!instr->operands[1].isConstant() || instr->operands[1].constantValue() >= 1024) { + encoding |= instr->operands[1].physReg().reg; + } else { + encoding |= instr->operands[1].constantValue() >> 2; + encoding |= 1 << 8; + } } out.push_back(encoding); /* SMRD instructions can take a literal on GFX6 & GFX7 */ - if (instr->operands[1].isConstant() && instr->operands[1].constantValue() >= 1024) + if (instr->operands.size() >= 2 && instr->operands[1].isConstant() && instr->operands[1].constantValue() >= 1024) out.push_back(instr->operands[1].constantValue() >> 2); return; } -- 2.30.2