[llvm] r245150 - AMDGPU/SI: Only look at live out SGPR defs

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 19:58:49 PDT 2015


Author: arsenm
Date: Fri Aug 14 21:58:49 2015
New Revision: 245150

URL: http://llvm.org/viewvc/llvm-project?rev=245150&view=rev
Log:
AMDGPU/SI: Only look at live out SGPR defs

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.

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

Modified: llvm/trunk/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp?rev=245150&r1=245149&r2=245150&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp Fri Aug 14 21:58:49 2015
@@ -128,9 +128,13 @@ bool SIFixSGPRLiveRanges::runOnMachineFu
           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)));




More information about the llvm-commits mailing list