[llvm] [AMDGPU] SIFixSgprCopies should not process twice VGPR to SGPR copies inserted by PHI preprocessing. (PR #134153)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 06:54:50 PDT 2025
================
@@ -971,16 +971,29 @@ void SIFixSGPRCopies::analyzeVGPRToSGPRCopy(MachineInstr* MI) {
}
} else if (Inst->getNumExplicitDefs() != 0) {
Register Reg = Inst->getOperand(0).getReg();
- if (TRI->isSGPRReg(*MRI, Reg) && !TII->isVALU(*Inst))
- for (auto &U : MRI->use_instructions(Reg))
- Users.push_back(&U);
+ if (TRI->isSGPRReg(*MRI, Reg) && !TII->isVALU(*Inst)) {
+ if (Reg.isVirtual()) {
+ for (auto &U : MRI->use_instructions(Reg))
+ Users.push_back(&U);
+ } else {
+ auto I = Inst->getIterator();
+ auto E = Inst->getParent()->end();
+ while (++I != E) {
+ if (I->readsRegister(Reg, TRI))
+ Users.push_back(&*I);
+ if (I->modifiesRegister(Reg, TRI))
+ break;
+ }
----------------
alex-t wrote:
Why we should not? We could have a long use chain with a physreg in the beginning. The code above ensures that we only consider users that use the value defined by the instruction that has written to the physreg. And this IS TESTED by the change in the existing tests.
https://github.com/llvm/llvm-project/pull/134153
More information about the llvm-commits
mailing list