AMDGPU/SI: Only look at live out SGPR defs
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 15 Aug 2015 02:58:49 +0000 (02:58 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 15 Aug 2015 02:58:49 +0000 (02:58 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245150 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp

index 016e2c8c886a03731b8054fb64cc865a12e4eac1..3dda827b671ac1fd7129ff20d07d3dd9c0d77b4d 100644 (file)
@@ -128,9 +128,13 @@ bool SIFixSGPRLiveRanges::runOnMachineFunction(MachineFunction &MF) {
           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)));