TableGen: Emit LaneMask for register classes without subregisters as ~0u
authorMatthias Braun <matze@braunis.de>
Tue, 10 Nov 2015 23:23:05 +0000 (23:23 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 10 Nov 2015 23:23:05 +0000 (23:23 +0000)
This makes it slightly easier to handle classes with and without
subregister uniformly.

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

lib/CodeGen/RegisterCoalescer.cpp
utils/TableGen/CodeGenRegisters.cpp

index 7739d64b45f8d37f65113750fc2032b977d04a14..176b2b5375f0779d6e4aeaf7b14d6743104fd7b8 100644 (file)
@@ -2975,22 +2975,25 @@ bool RegisterCoalescer::runOnMachineFunction(MachineFunction &fn) {
     if (MRI->recomputeRegClass(Reg)) {
       DEBUG(dbgs() << PrintReg(Reg) << " inflated to "
                    << TRI->getRegClassName(MRI->getRegClass(Reg)) << '\n');
+      ++NumInflated;
+
       LiveInterval &LI = LIS->getInterval(Reg);
-      LaneBitmask MaxMask = MRI->getMaxLaneMaskForVReg(Reg);
-      if (MaxMask == 0) {
+      if (LI.hasSubRanges()) {
         // If the inflated register class does not support subregisters anymore
         // remove the subranges.
-        LI.clearSubRanges();
-      } else {
+        if (!MRI->shouldTrackSubRegLiveness(Reg)) {
+          LI.clearSubRanges();
+        } else {
 #ifndef NDEBUG
-        // If subranges are still supported, then the same subregs should still
-        // be supported.
-        for (LiveInterval::SubRange &S : LI.subranges()) {
-          assert ((S.LaneMask & ~MaxMask) == 0);
-        }
+          LaneBitmask MaxMask = MRI->getMaxLaneMaskForVReg(Reg);
+          // If subranges are still supported, then the same subregs
+          // should still be supported.
+          for (LiveInterval::SubRange &S : LI.subranges()) {
+            assert((S.LaneMask & ~MaxMask) == 0);
+          }
 #endif
+        }
       }
-      ++NumInflated;
     }
   }
 
index c9e6d1d379de95a50921b040337f71efec9e1230..f6eadce9c3d88a199cdc12644ac727ca36c6ab7b 100644 (file)
@@ -1274,6 +1274,12 @@ void CodeGenRegBank::computeSubRegLaneMasks() {
         continue;
       LaneMask |= SubRegIndex.LaneMask;
     }
+
+    // For classes without any subregisters set LaneMask to ~0u instead of 0.
+    // This makes it easier for client code to handle classes uniformly.
+    if (LaneMask == 0)
+      LaneMask = ~0u;
+
     RegClass.LaneMask = LaneMask;
   }
 }