[PATCH] D17590: AMDGPU/SI: Don't try to move scratch wave offset when there are no free SGPRs

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 2 19:49:52 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL262577: AMDGPU/SI: Don't try to move scratch wave offset when there are no free SGPRs (authored by tstellar).

Changed prior to commit:
  http://reviews.llvm.org/D17590?vs=49001&id=49699#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17590

Files:
  llvm/trunk/lib/Target/AMDGPU/SIFrameLowering.cpp

Index: llvm/trunk/lib/Target/AMDGPU/SIFrameLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIFrameLowering.cpp
+++ llvm/trunk/lib/Target/AMDGPU/SIFrameLowering.cpp
@@ -165,10 +165,22 @@
 
     if (ScratchWaveOffsetReg == TRI->reservedPrivateSegmentWaveByteOffsetReg(MF)) {
       MachineRegisterInfo &MRI = MF.getRegInfo();
-      // Skip the last 2 elements because the last one is reserved for VCC, and
-      // this is the 2nd to last element already.
       unsigned NumPreloaded = MFI->getNumPreloadedSGPRs();
-      for (MCPhysReg Reg : getAllSGPRs().drop_back(6).slice(NumPreloaded)) {
+
+      // We need to drop register from the end of the list that we cannot use
+      // for the scratch wave offset.
+      // + 2 s102 and s103 do not exist on VI.
+      // + 2 for vcc
+      // + 2 for xnack_mask
+      // + 2 for flat_scratch
+      // + 4 for registers reserved for scratch resource register
+      // + 1 for register reserved for scratch wave offset.  (By exluding this
+      //     register from the list to consider, it means that when this
+      //     register is being used for the scratch wave offset and there
+      //     are no other free SGPRs, then the value will stay in this register.
+      // ----
+      //  13
+      for (MCPhysReg Reg : getAllSGPRs().drop_back(13).slice(NumPreloaded)) {
         // Pick the first unallocated SGPR. Be careful not to pick an alias of the
         // scratch descriptor, since we haven’t added its uses yet.
         if (!MRI.isPhysRegUsed(Reg)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17590.49699.patch
Type: text/x-patch
Size: 1591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160303/34bb5b22/attachment.bin>


More information about the llvm-commits mailing list