aco/ra: fix kill flags after renaming fixed Operands

Suggested-by: Rhys Perry <pendingchaos02@gmail.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28876>
(cherry picked from commit be1e68b4ee)
This commit is contained in:
Daniel Schürmann 2024-04-23 15:06:38 +02:00 committed by Eric Engestrom
parent 714f7bd58b
commit 8f0d4074ad
2 changed files with 25 additions and 19 deletions

View file

@ -2034,7 +2034,7 @@
"description": "aco/ra: fix kill flags after renaming fixed Operands",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -842,7 +842,7 @@ update_renames(ra_ctx& ctx, RegisterFile& reg_file,
assert(ctx.assignments.size() == ctx.program->peekAllocationId());
/* check if we moved an operand */
bool first = true;
bool first[2] = {true, true};
bool fill = true;
for (unsigned i = 0; i < instr->operands.size(); i++) {
Operand& op = instr->operands[i];
@ -850,25 +850,31 @@ update_renames(ra_ctx& ctx, RegisterFile& reg_file,
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())
bool omit_renaming = (flags & rename_precolored_ops) && op.isFixed() &&
op.physReg() != copy.second.physReg();
/* Omit renaming in some cases for p_create_vector in order to avoid
* unnecessary shuffle code. */
if (!(flags & rename_not_killed_ops) && !op.isKillBeforeDef()) {
omit_renaming = true;
for (std::pair<Operand, Definition>& pc : parallelcopies) {
PhysReg def_reg = pc.second.physReg();
omit_renaming &= def_reg > copy.first.physReg()
? (copy.first.physReg() + copy.first.size() <= def_reg.reg())
: (def_reg + pc.second.size() <= copy.first.physReg().reg());
}
}
/* Fix the kill flags */
if (first[omit_renaming])
op.setFirstKill(omit_renaming || op.isKill());
else
op.setKill(omit_renaming || op.isKill());
first[omit_renaming] = false;
if (omit_renaming)
continue;
bool omit_renaming = !(flags & rename_not_killed_ops) && !op.isKillBeforeDef();
for (std::pair<Operand, Definition>& pc : parallelcopies) {
PhysReg def_reg = pc.second.physReg();
omit_renaming &= def_reg > copy.first.physReg()
? (copy.first.physReg() + copy.first.size() <= def_reg.reg())
: (def_reg + pc.second.size() <= copy.first.physReg().reg());
}
if (omit_renaming) {
if (first)
op.setFirstKill(true);
else
op.setKill(true);
first = false;
continue;
}
op.setTemp(copy.second.getTemp());
op.setFixed(copy.second.physReg());