[llvm] [AMDGPU] Generate waterfall for calls with SGPR(inreg) argument (PR #146997)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 20 21:33:20 PDT 2025
================
@@ -1128,6 +1169,45 @@ void SIFixSGPRCopies::lowerVGPR2SGPRCopies(MachineFunction &MF) {
}
}
+void SIFixSGPRCopies::lowerPysicalSGPRInsts(MachineFunction &MF) {
+ for (auto &Entry : WaterFalls) {
+ MachineInstr *MI = Entry.first;
+ const V2PhysSCopyInfo &Info = Entry.second;
+ assert((Info.MOs.size() != 0 && Info.SGPRs.size() == Info.MOs.size()) &&
+ "Error in MOs or SGPRs size.");
+
+ if (MI->getOpcode() == AMDGPU::SI_CALL_ISEL) {
----------------
Shoreshen wrote:
Hi @jmmartinez , I think the call it self is legal, so we probably cannot put this process in `legalizeOperands`......... If we want to do this, we will have to pass extra parameters to indicate that the CALL need to be modified.
What I try is to move it into `moveToVALUImpl`, but there are also problems:
1. In `moveToVALUImpl` it will run into the branch:
```
if (Inst.isCopy() && DstReg.isPhysical() &&
RI.isVGPR(MRI, Inst.getOperand(1).getReg()))
```
Which will create READFIRSTLANE for sgpr, directly erase the COPY and return (didn't add call into worklist). We have to skip this branch because call should be handled after all COPY was handled.
2. By allowing COPY to physical reg into the list, it will fail some tests such as `llvm/test/CodeGen/AMDGPU/si-fix-sgpr-copies-copy-to-sgpr.mir`.
https://github.com/llvm/llvm-project/pull/146997
More information about the llvm-commits
mailing list