diff --git a/src/amd/compiler/aco_assembler.cpp b/src/amd/compiler/aco_assembler.cpp index 057545406e8..789ea65341f 100644 --- a/src/amd/compiler/aco_assembler.cpp +++ b/src/amd/compiler/aco_assembler.cpp @@ -88,7 +88,7 @@ emit_instruction(asm_context& ctx, std::vector& out, Instruction* inst 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)); + instr->operands[1] = Operand::literal32(instr->operands[1].constantValue()); } uint32_t opcode = ctx.opcode[(int)instr->opcode]; @@ -912,8 +912,8 @@ emit_long_jump(asm_context& ctx, SOPP_instruction* branch, bool backwards, instr.reset(bld.sop1(aco_opcode::s_getpc_b64, branch->definitions[0]).instr); emit_instruction(ctx, out, instr.get()); - instr.reset(bld.sop2(aco_opcode::s_addc_u32, def_tmp_lo, op_tmp_lo, Operand::zero()).instr); - instr->operands[1].setFixed(PhysReg{255}); /* this operand has to be a literal */ + instr.reset( + bld.sop2(aco_opcode::s_addc_u32, def_tmp_lo, op_tmp_lo, Operand::literal32(0)).instr); emit_instruction(ctx, out, instr.get()); branch->pass_flags = out.size(); diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 28c3d445262..9cb5681da68 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -644,6 +644,17 @@ public: return op; } + static Operand literal32(uint32_t v) noexcept + { + Operand op; + op.control_ = 0; + op.data_.i = v; + op.isConstant_ = true; + op.constSize = 2; + op.setFixed(PhysReg{255}); + return op; + } + explicit Operand(RegClass type) noexcept { isUndef_ = true; diff --git a/src/amd/compiler/aco_lower_to_hw_instr.cpp b/src/amd/compiler/aco_lower_to_hw_instr.cpp index 6e9606c47d3..20069adc1c2 100644 --- a/src/amd/compiler/aco_lower_to_hw_instr.cpp +++ b/src/amd/compiler/aco_lower_to_hw_instr.cpp @@ -1973,10 +1973,7 @@ emit_set_mode(Builder& bld, float_mode new_mode, bool set_round, bool set_denorm bld.sopp(aco_opcode::s_denorm_mode, -1, new_mode.denorm); } else if (set_round || set_denorm) { /* "((size - 1) << 11) | register" (MODE is encoded as register 1) */ - Instruction* instr = - bld.sopk(aco_opcode::s_setreg_imm32_b32, Operand::c8(new_mode.val), (7 << 11) | 1).instr; - /* has to be a literal */ - instr->operands[0].setFixed(PhysReg{255}); + bld.sopk(aco_opcode::s_setreg_imm32_b32, Operand::literal32(new_mode.val), (7 << 11) | 1); } } diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index 4e8a701ab79..b4bf499d80b 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -4595,7 +4595,7 @@ apply_literals(opt_ctx& ctx, aco_ptr& instr) Operand op = instr->operands[i]; unsigned bits = get_operand_size(instr, i); if (op.isTemp() && ctx.info[op.tempId()].is_literal(bits) && ctx.uses[op.tempId()] == 0) { - Operand literal = Operand::c32(ctx.info[op.tempId()].val); + Operand literal = Operand::literal32(ctx.info[op.tempId()].val); instr->format = withoutDPP(instr->format); if (instr->isVALU() && i > 0 && instr->format != Format::VOP3P) to_VOP3(ctx, instr);