aco/ra: only rename fixed Operands if the copy-location matches

With epilogs, the same Operand can be fixed to multiple registers.

Fixes: 061b8bfd29 ('aco/ra: rework fixed operands')
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18485>
This commit is contained in:
Daniel Schürmann 2022-09-08 11:17:25 +02:00 committed by Marge Bot
parent cf7ada973a
commit 6fcabb3b02
2 changed files with 9 additions and 2 deletions

View file

@ -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<Operand, Definition>& 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

View file

@ -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)));