[llvm] AMDGPU: Try to unspill VGPRs after rewriting MFMAs to AGPR form (PR #154323)

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 07:24:48 PDT 2025


================
@@ -391,6 +414,133 @@ bool AMDGPURewriteAGPRCopyMFMAImpl::tryFoldCopiesFromAGPR(
   return MadeChange;
 }
 
+void AMDGPURewriteAGPRCopyMFMAImpl::replaceSpillWithCopyToVReg(
+    MachineInstr &SpillMI, int SpillFI, Register VReg) const {
+  const DebugLoc &DL = SpillMI.getDebugLoc();
+  MachineBasicBlock &MBB = *SpillMI.getParent();
+  MachineInstr *NewCopy;
+  if (SpillMI.mayStore()) {
+    NewCopy = BuildMI(MBB, SpillMI, DL, TII.get(TargetOpcode::COPY), VReg)
+                  .add(SpillMI.getOperand(0));
----------------
qcolombet wrote:

I think I'm missing something, but don't we only get spills by constructions?
I.e., can it be something else than `mayStore` here?

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


More information about the llvm-commits mailing list