aco: fix emitting SMEM instructions with no operands on GFX6-GFX7
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 15 Jan 2020 12:08:17 +0000 (13:08 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 16 Jan 2020 07:18:18 +0000 (08:18 +0100)
Like s_memtime.

Fixes dEQP-VK.glsl.shader_clock.* on GFX6.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3407>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3407>

src/amd/compiler/aco_assembler.cpp

index 69b8a9b33c6c529977e0ff0eafc4ba1508b4ada2..a9dd6b441e2a35915d973f95d7a4a548bbb3c479 100644 (file)
@@ -154,15 +154,17 @@ void emit_instruction(asm_context& ctx, std::vector<uint32_t>& 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;
       }