[llvm] r285756 - AMDGPU: Stop creating unused virtual registers

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 14:58:07 PDT 2016


Author: arsenm
Date: Tue Nov  1 16:58:07 2016
New Revision: 285756

URL: http://llvm.org/viewvc/llvm-project?rev=285756&view=rev
Log:
AMDGPU: Stop creating unused virtual registers

These are only used in the spill to VMEM path. Move them to
the one use.

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=285756&r1=285755&r2=285756&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp Tue Nov  1 16:58:07 2016
@@ -491,7 +491,6 @@ void SIRegisterInfo::spillSGPR(MachineBa
   // SubReg carries the "Kill" flag when SubReg == SuperReg.
   unsigned SubKillState = getKillRegState((NumSubRegs == 1) && IsKill);
   for (unsigned i = 0, e = NumSubRegs; i < e; ++i) {
-    unsigned TmpReg = MRI.createVirtualRegister(&AMDGPU::VGPR_32RegClass);
     unsigned SubReg = NumSubRegs == 1 ?
       SuperReg : getSubReg(SuperReg, getSubRegFromChannel(i));
 
@@ -522,6 +521,10 @@ void SIRegisterInfo::spillSGPR(MachineBa
     } else {
       // Spill SGPR to a frame index.
       // FIXME we should use S_STORE_DWORD here for VI.
+
+      // TODO: Should VI try to spill to VGPR and then spill to SMEM?
+      unsigned TmpReg = MRI.createVirtualRegister(&AMDGPU::VGPR_32RegClass);
+
       MachineInstrBuilder Mov
         = BuildMI(*MBB, MI, DL, TII->get(AMDGPU::V_MOV_B32_e32), TmpReg)
         .addReg(SubReg, SubKillState);
@@ -582,7 +585,6 @@ void SIRegisterInfo::restoreSGPR(Machine
   }
 
   for (unsigned i = 0, e = NumSubRegs; i < e; ++i) {
-    unsigned TmpReg = MRI.createVirtualRegister(&AMDGPU::VGPR_32RegClass);
     unsigned SubReg = NumSubRegs == 1 ?
       SuperReg : getSubReg(SuperReg, getSubRegFromChannel(i));
 
@@ -600,6 +602,7 @@ void SIRegisterInfo::restoreSGPR(Machine
       // Restore SGPR from a stack slot.
       // FIXME: We should use S_LOAD_DWORD here for VI.
 
+      unsigned TmpReg = MRI.createVirtualRegister(&AMDGPU::VGPR_32RegClass);
       unsigned Align = FrameInfo.getObjectAlignment(Index);
       unsigned Size = FrameInfo.getObjectSize(Index);
 




More information about the llvm-commits mailing list