[llvm-commits] [llvm] r158526 - /llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Jun 15 10:36:49 PDT 2012


Author: stoklund
Date: Fri Jun 15 12:36:48 2012
New Revision: 158526

URL: http://llvm.org/viewvc/llvm-project?rev=158526&view=rev
Log:
Use regunit liveness in RegisterCoalescer when it is available.

We only do very limited physreg coalescing now, but we still merge
virtual registers into reserved registers.

Modified:
    llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp

Modified: llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp?rev=158526&r1=158525&r2=158526&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp Fri Jun 15 12:36:48 2012
@@ -870,7 +870,7 @@
                                           unsigned DstReg,
                                           unsigned SubIdx) {
   bool DstIsPhys = TargetRegisterInfo::isPhysicalRegister(DstReg);
-  LiveInterval &DstInt = LIS->getInterval(DstReg);
+  LiveInterval *DstInt = DstIsPhys ? 0 : &LIS->getInterval(DstReg);
 
   // Update LiveDebugVariables.
   LDV->renameRegister(SrcReg, DstReg, SubIdx);
@@ -883,8 +883,8 @@
 
     // If SrcReg wasn't read, it may still be the case that DstReg is live-in
     // because SrcReg is a sub-register.
-    if (!Reads && SubIdx)
-      Reads = DstInt.liveAt(LIS->getInstructionIndex(UseMI));
+    if (DstInt && !Reads && SubIdx)
+      Reads = DstInt->liveAt(LIS->getInstructionIndex(UseMI));
 
     // Replace SrcReg with DstReg in all UseMI operands.
     for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
@@ -1102,16 +1102,24 @@
 
   // Deny any overlapping intervals.  This depends on all the reserved
   // register live ranges to look like dead defs.
-  for (MCRegAliasIterator AS(CP.getDstReg(), TRI, true); AS.isValid(); ++AS) {
-    if (!LIS->hasInterval(*AS)) {
-      // Make sure at least DstReg itself exists before attempting a join.
-      if (*AS == CP.getDstReg())
-        LIS->getOrCreateInterval(CP.getDstReg());
-      continue;
-    }
-    if (RHS.overlaps(LIS->getInterval(*AS))) {
-      DEBUG(dbgs() << "\t\tInterference: " << PrintReg(*AS, TRI) << '\n');
-      return false;
+  if (LIS->trackingRegUnits()) {
+    for (MCRegUnitIterator UI(CP.getDstReg(), TRI); UI.isValid(); ++UI)
+      if (RHS.overlaps(LIS->getRegUnit(*UI))) {
+        DEBUG(dbgs() << "\t\tInterference: " << PrintRegUnit(*UI, TRI) << '\n');
+        return false;
+      }
+  } else {
+    for (MCRegAliasIterator AS(CP.getDstReg(), TRI, true); AS.isValid(); ++AS) {
+      if (!LIS->hasInterval(*AS)) {
+        // Make sure at least DstReg itself exists before attempting a join.
+        if (*AS == CP.getDstReg())
+          LIS->getOrCreateInterval(CP.getDstReg());
+        continue;
+      }
+      if (RHS.overlaps(LIS->getInterval(*AS))) {
+        DEBUG(dbgs() << "\t\tInterference: " << PrintReg(*AS, TRI) << '\n');
+        return false;
+      }
     }
   }
   // Skip any value computations, we are not adding new values to the





More information about the llvm-commits mailing list