[llvm] [AMDGPU] Generate waterfall for calls with SGPR(inreg) argument (PR #146997)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 18:26:25 PDT 2026
================
@@ -7828,6 +7850,90 @@ void SIInstrInfo::moveToVALU(SIInstrWorklist &Worklist,
assert(Worklist.empty() &&
"Deferred MachineInstr are not supposed to re-populate worklist");
}
+
+ for (std::pair<MachineInstr *, V2PhysSCopyInfo> &Entry : Worklist.WaterFalls)
+ if (Entry.first->getOpcode() == AMDGPU::SI_CALL_ISEL)
+ createWaterFallForSiCall(Entry.first, MDT, Entry.second.MOs,
+ Entry.second.SGPRs);
+
+ for (std::pair<MachineInstr *, bool> Entry : Worklist.V2SPhyCopiesToErase)
+ if (Entry.second)
+ Entry.first->eraseFromParent();
+}
+void SIInstrInfo::createReadFirstLaneFromCopyToPhysReg(
+ MachineRegisterInfo &MRI, Register DstReg, MachineInstr &Inst) const {
+ // If it's a copy of a VGPR to a physical SGPR, insert a V_READFIRSTLANE and
+ // hope for the best.
+ const TargetRegisterClass *DstRC = RI.getRegClassForReg(MRI, DstReg);
+ ArrayRef<int16_t> BaseIndices = RI.getRegSplitParts(DstRC, 4);
----------------
Shoreshen wrote:
Hi @arsenm , these 2 seems only work inside [SIInstrInfo.cpp](https://github.com/llvm/llvm-project/pull/146997/files/d88c03dea7670f74d934e70d8621bc1c02e368c7#diff-744f96b5d6f7f2ed21a65e4b3717f9bf26b5fbaad0aeb6c043d49d8b3458409e), so I put it inside the `moveToVALU` function.
If need to move to [SIInstrInfo.cpp](https://github.com/llvm/llvm-project/pull/146997/files/d88c03dea7670f74d934e70d8621bc1c02e368c7#diff-744f96b5d6f7f2ed21a65e4b3717f9bf26b5fbaad0aeb6c043d49d8b3458409e), since it goes across between different files, I may have to pass it in using function parameter??
https://github.com/llvm/llvm-project/pull/146997
More information about the llvm-commits
mailing list