[PATCH] D11880: AMDGPU/SI: Only look at live out SGPR defs

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 8 19:05:10 PDT 2015


arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: llvm-commits.
Herald added a subscriber: MatzeB.

When trying to fix SGPR live ranges, skip defs that are
killed in the same block as the def. I don't think
we need to worry about these cases as long as the
live ranges of the SGPRs in dominating blocks are
correct.
    
This reduces the number of elements the second
loop over the function needs to look at, and makes
it generally easier to understand. The second loop
also only considers if the live range is live
in to a block, which logically means it
must have been live out from another.

http://reviews.llvm.org/D11880

Files:
  lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp

Index: lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
===================================================================
--- lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
+++ lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
@@ -135,9 +135,13 @@
           continue;
         unsigned Def = MO.getReg();
         if (TargetRegisterInfo::isVirtualRegister(Def)) {
-          if (TRI->isSGPRClass(MRI.getRegClass(Def)))
-            SGPRLiveRanges.push_back(
-                std::make_pair(Def, &LIS->getInterval(Def)));
+          if (TRI->isSGPRClass(MRI.getRegClass(Def))) {
+            // Only consider defs that are live outs. We don't care about def /
+            // use within the same block.
+            LiveRange &LR = LIS->getInterval(Def);
+            if (LIS->isLiveOutOfMBB(LR, &MBB))
+              SGPRLiveRanges.push_back(std::make_pair(Def, &LR));
+          }
         } else if (TRI->isSGPRClass(TRI->getPhysRegClass(Def))) {
             SGPRLiveRanges.push_back(
                 std::make_pair(Def, &LIS->getRegUnit(Def)));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11880.31605.patch
Type: text/x-patch
Size: 1033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150809/04bd59bd/attachment.bin>


More information about the llvm-commits mailing list