[llvm] [AMDGPU] Pick available high VGPR for CSR SGPR spilling (PR #78669)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 00:49:12 PST 2024


================
@@ -312,6 +312,35 @@ bool SIMachineFunctionInfo::isCalleeSavedReg(const MCPhysReg *CSRegs,
   return false;
 }
 
+void SIMachineFunctionInfo::shiftSpillPhysVGPRsToLowestRange(
+    MachineFunction &MF) {
+  for (unsigned I = 0, E = SpillPhysVGPRs.size(); I < E; ++I) {
+    Register Reg = SpillPhysVGPRs[I];
+    const SIRegisterInfo *TRI =
+        MF.getSubtarget<GCNSubtarget>().getRegisterInfo();
+    MachineRegisterInfo &MRI = MF.getRegInfo();
+    Register NewReg =
+        TRI->findUnusedRegister(MRI, &AMDGPU::VGPR_32RegClass, MF);
+    if (!NewReg || NewReg >= Reg)
+      continue;
----------------
arsenm wrote:

There's no point in continuing the loop if this failed once 

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


More information about the llvm-commits mailing list