diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 248460746e7..9cbc20810aa 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -769,6 +769,7 @@ adjust_max_used_regs(ra_ctx& ctx, RegClass rc, unsigned reg) enum UpdateRenames { rename_not_killed_ops = 0x1, fill_killed_ops = 0x2, + rename_precolored_ops = 0x4, }; MESA_DEFINE_CPP_ENUM_BITFIELD_OPERATORS(UpdateRenames); @@ -848,6 +849,11 @@ update_renames(ra_ctx& ctx, RegisterFile& reg_file, if (!op.isTemp()) continue; if (op.tempId() == copy.first.tempId()) { + /* only rename precolored operands if the copy-location matches */ + if ((flags & rename_precolored_ops) && op.isFixed() && + op.physReg() != copy.second.physReg()) + continue; + bool omit_renaming = !(flags & rename_not_killed_ops) && !op.isKillBeforeDef(); for (std::pair& pc : parallelcopies) { PhysReg def_reg = pc.second.physReg(); @@ -2017,7 +2023,8 @@ handle_fixed_operands(ra_ctx& ctx, RegisterFile& register_file, } get_regs_for_copies(ctx, tmp_file, parallelcopy, blocking_vars, instr, PhysRegInterval()); - update_renames(ctx, register_file, parallelcopy, instr, rename_not_killed_ops | fill_killed_ops); + update_renames(ctx, register_file, parallelcopy, instr, + rename_not_killed_ops | fill_killed_ops | rename_precolored_ops); } void diff --git a/src/amd/compiler/tests/test_regalloc.cpp b/src/amd/compiler/tests/test_regalloc.cpp index 7d9bf38413b..9052e80dc4f 100644 --- a/src/amd/compiler/tests/test_regalloc.cpp +++ b/src/amd/compiler/tests/test_regalloc.cpp @@ -181,7 +181,7 @@ BEGIN_TEST(regalloc.precolor.different_regs) return; //! v1: %tmp1:v[1], v1: %tmp2:v[2] = p_parallelcopy %tmp0:v[0], %tmp0:v[0] - //! p_unit_test %tmp1:v[1], %tmp1:v[1], %tmp1:v[1] + //! p_unit_test %tmp0:v[0], %tmp1:v[1], %tmp2:v[2] bld.pseudo(aco_opcode::p_unit_test, Operand(inputs[0], PhysReg(256+0)), Operand(inputs[0], PhysReg(256+1)), Operand(inputs[0], PhysReg(256+2)));