[llvm] r287842 - AMDGPU: Remove m0 spilling code

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 23 16:26:44 PST 2016


Author: arsenm
Date: Wed Nov 23 18:26:44 2016
New Revision: 287842

URL: http://llvm.org/viewvc/llvm-project?rev=287842&view=rev
Log:
AMDGPU: Remove m0 spilling code

Since m0 isn't allocatable it should never be spilled anymore.

Modified:
    llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp

Modified: llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp?rev=287842&r1=287841&r2=287842&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp Wed Nov 23 18:26:44 2016
@@ -517,6 +517,8 @@ void SIRegisterInfo::spillSGPR(MachineBa
 
   bool SpillToSMEM = ST.hasScalarStores() && EnableSpillSGPRToSMEM;
 
+  assert(SuperReg != AMDGPU::M0 && "m0 should never spill");
+
   const unsigned EltSize = 4;
 
   // SubReg carries the "Kill" flag when SubReg == SuperReg.
@@ -526,19 +528,6 @@ void SIRegisterInfo::spillSGPR(MachineBa
       SuperReg : getSubReg(SuperReg, getSubRegFromChannel(i));
 
     if (SpillToSMEM) {
-      if (SuperReg == AMDGPU::M0) {
-        assert(NumSubRegs == 1);
-        unsigned CopyM0
-          = MRI.createVirtualRegister(&AMDGPU::SReg_32_XM0RegClass);
-
-        BuildMI(*MBB, MI, DL, TII->get(AMDGPU::COPY), CopyM0)
-          .addReg(AMDGPU::M0, getKillRegState(IsKill));
-
-        // The real spill now kills the temp copy.
-        SubReg = SuperReg = CopyM0;
-        IsKill = true;
-      }
-
       int64_t FrOffset = FrameInfo.getObjectOffset(Index);
       unsigned Align = FrameInfo.getObjectAlignment(Index);
       MachinePointerInfo PtrInfo
@@ -576,18 +565,6 @@ void SIRegisterInfo::spillSGPR(MachineBa
     struct SIMachineFunctionInfo::SpilledReg Spill =
       MFI->getSpilledReg(MF, Index, i);
     if (Spill.hasReg()) {
-      if (SuperReg == AMDGPU::M0) {
-        assert(NumSubRegs == 1);
-        unsigned CopyM0
-          = MRI.createVirtualRegister(&AMDGPU::SReg_32_XM0RegClass);
-        BuildMI(*MBB, MI, DL, TII->get(AMDGPU::S_MOV_B32), CopyM0)
-          .addReg(SuperReg, getKillRegState(IsKill));
-
-        // The real spill now kills the temp copy.
-        SubReg = SuperReg = CopyM0;
-        IsKill = true;
-      }
-
       BuildMI(*MBB, MI, DL,
               TII->getMCOpcodeFromPseudo(AMDGPU::V_WRITELANE_B32),
               Spill.VGPR)
@@ -654,13 +631,7 @@ void SIRegisterInfo::restoreSGPR(Machine
   unsigned SuperReg = MI->getOperand(0).getReg();
   bool SpillToSMEM = ST.hasScalarStores() && EnableSpillSGPRToSMEM;
 
-  // m0 is not allowed as with readlane/writelane, so a temporary SGPR and
-  // extra copy is needed.
-  bool IsM0 = (SuperReg == AMDGPU::M0);
-  if (IsM0) {
-    assert(NumSubRegs == 1);
-    SuperReg = MRI.createVirtualRegister(&AMDGPU::SReg_32_XM0RegClass);
-  }
+  assert(SuperReg != AMDGPU::M0 && "m0 should never spill");
 
   int64_t FrOffset = FrameInfo.getObjectOffset(Index);
 
@@ -745,11 +716,6 @@ void SIRegisterInfo::restoreSGPR(Machine
     }
   }
 
-  if (IsM0 && SuperReg != AMDGPU::M0) {
-    BuildMI(*MBB, MI, DL, TII->get(AMDGPU::S_MOV_B32), AMDGPU::M0)
-      .addReg(SuperReg);
-  }
-
   MI->eraseFromParent();
 }
 




More information about the llvm-commits mailing list