[llvm] [AMDGPU] Generate waterfall for calls with SGPR(inreg) argument (PR #146997)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 10 00:51:12 PDT 2025


================
@@ -7630,6 +7654,86 @@ 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)
+    createWaterFall(Entry.first, MDT, Entry.second.MOs, Entry.second.SGPRs);
+
+  for (std::pair<MachineInstr *, bool> Entry : Worklist.V2PhySCopiesToErase)
+    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.
+  unsigned RegSize = RI.getRegSizeInBits(DstReg, MRI);
+  unsigned NumSubRegs = RegSize / 32;
----------------
arsenm wrote:

Better to do this in terms of register classes than register sizes 

https://github.com/llvm/llvm-project/pull/146997


More information about the llvm-commits mailing list