[PATCH] D25220: AMDGPU: Do not re-use tmpreg in spill/restore lowering

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 3 18:23:09 PDT 2016


MatzeB created this revision.
MatzeB added a reviewer: arsenm.
MatzeB added a subscriber: llvm-commits.
MatzeB set the repository for this revision to rL LLVM.
Herald added a reviewer: tstellarAMD.
Herald added subscribers: tony-tye, yaxunl, nhaehnle, wdng, kzhuravl, mcrosier.

The register scavenging code does not support multiple definitions of
the same vreg.

Found this while working on some register scavenging changes. While having a vreg with multiple definitions is already a problem with the current register scavenger it is very unlikely to cause actual problem in practice. The new code however will use that property more aggressively.


Repository:
  rL LLVM

https://reviews.llvm.org/D25220

Files:
  lib/Target/AMDGPU/SIRegisterInfo.cpp


Index: lib/Target/AMDGPU/SIRegisterInfo.cpp
===================================================================
--- lib/Target/AMDGPU/SIRegisterInfo.cpp
+++ lib/Target/AMDGPU/SIRegisterInfo.cpp
@@ -427,13 +427,13 @@
     case AMDGPU::SI_SPILL_S64_SAVE:
     case AMDGPU::SI_SPILL_S32_SAVE: {
       unsigned NumSubRegs = getNumSubRegsForSpillOp(MI->getOpcode());
-      unsigned TmpReg = MRI.createVirtualRegister(&AMDGPU::VGPR_32RegClass);
       unsigned SuperReg = MI->getOperand(0).getReg();
       bool IsKill = MI->getOperand(0).isKill();
 
       // 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));
 
@@ -507,7 +507,6 @@
     case AMDGPU::SI_SPILL_S64_RESTORE:
     case AMDGPU::SI_SPILL_S32_RESTORE: {
       unsigned NumSubRegs = getNumSubRegsForSpillOp(MI->getOpcode());
-      unsigned TmpReg = MRI.createVirtualRegister(&AMDGPU::VGPR_32RegClass);
       unsigned SuperReg = MI->getOperand(0).getReg();
 
       // m0 is not allowed as with readlane/writelane, so a temporary SGPR and
@@ -519,6 +518,7 @@
       }
 
       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));
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25220.73386.patch
Type: text/x-patch
Size: 1615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161004/f4fa29c7/attachment.bin>


More information about the llvm-commits mailing list