aco: fix encoding of certain s_setreg_imm32_b32 instructions
authorRhys Perry <pendingchaos02@gmail.com>
Thu, 11 Jun 2020 13:06:32 +0000 (14:06 +0100)
committerMarge Bot <eric+marge@anholt.net>
Mon, 15 Jun 2020 18:24:22 +0000 (18:24 +0000)
If the mode is too small, the operand will be an inline constant and the
literal dword won't be written.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5245>

src/amd/compiler/aco_lower_to_hw_instr.cpp

index 5e93dc6..441e1b6 100644 (file)
@@ -1658,7 +1658,9 @@ void lower_to_hw_instr(Program* program)
          assert(block->kind & block_kind_top_level);
          uint32_t mode = block->fp_mode.val;
          /* "((size - 1) << 11) | register" (MODE is encoded as register 1) */
-         bld.sopk(aco_opcode::s_setreg_imm32_b32, Operand(mode), (7 << 11) | 1);
+         Instruction *instr = bld.sopk(aco_opcode::s_setreg_imm32_b32, Operand(mode), (7 << 11) | 1).instr;
+         /* has to be a literal */
+         instr->operands[0].setFixed(PhysReg{255});
       }
 
       for (size_t j = 0; j < block->instructions.size(); j++) {