[llvm-commits] [llvm] r124918 - /llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Feb 4 17:06:39 PST 2011


Author: stoklund
Date: Fri Feb  4 19:06:39 2011
New Revision: 124918

URL: http://llvm.org/viewvc/llvm-project?rev=124918&view=rev
Log:
Be more strict about the first/last interference-free use.

If the interference overlaps the instruction, we cannot separate it.

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

Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=124918&r1=124917&r2=124918&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Fri Feb  4 19:06:39 2011
@@ -716,6 +716,15 @@
 
     // Block has interference.
     DEBUG(dbgs() << ", interference to " << IP.second);
+
+    if (!BI.LiveThrough && IP.second <= BI.Def) {
+      // The interference doesn't reach the outgoing segment.
+      DEBUG(dbgs() << " doesn't affect def from " << BI.Def << '\n');
+      SE.useIntv(BI.Def, Stop);
+      continue;
+    }
+
+
     if (!BI.Uses) {
       // No uses in block, avoid interference by reloading as late as possible.
       DEBUG(dbgs() << ", no uses.\n");
@@ -723,11 +732,14 @@
       assert(SegStart >= IP.second && "Couldn't avoid interference");
       continue;
     }
-    if (IP.second < BI.LastUse && IP.second <= BI.LastSplitPoint) {
+
+    if (IP.second.getBoundaryIndex() < BI.LastUse &&
+        IP.second.getBoundaryIndex() <= BI.LastSplitPoint) {
       // There are interference-free uses at the end of the block.
       // Find the first use that can get the live-out register.
       SmallVectorImpl<SlotIndex>::const_iterator UI =
-        std::lower_bound(SA->UseSlots.begin(), SA->UseSlots.end(), IP.second);
+        std::lower_bound(SA->UseSlots.begin(), SA->UseSlots.end(),
+                         IP.second.getBoundaryIndex());
       assert(UI != SA->UseSlots.end() && "Couldn't find last use");
       SlotIndex Use = *UI;
       DEBUG(dbgs() << ", free use at " << Use << ".\n");
@@ -798,6 +810,14 @@
 
     // Block has interference.
     DEBUG(dbgs() << ", interference from " << IP.first);
+
+    if (!BI.LiveThrough && IP.first >= BI.Kill) {
+      // The interference doesn't reach the outgoing segment.
+      DEBUG(dbgs() << " doesn't affect kill at " << BI.Kill << '\n');
+      SE.useIntv(Start, BI.Kill);
+      continue;
+    }
+
     if (!BI.Uses) {
       // No uses in block, avoid interference by spilling as soon as possible.
       DEBUG(dbgs() << ", no uses.\n");
@@ -805,11 +825,12 @@
       assert(SegEnd <= IP.first && "Couldn't avoid interference");
       continue;
     }
-    if (IP.first > BI.FirstUse) {
+    if (IP.first.getBaseIndex() > BI.FirstUse) {
       // There are interference-free uses at the beginning of the block.
       // Find the last use that can get the register.
       SmallVectorImpl<SlotIndex>::const_iterator UI =
-        std::lower_bound(SA->UseSlots.begin(), SA->UseSlots.end(), IP.first);
+        std::lower_bound(SA->UseSlots.begin(), SA->UseSlots.end(),
+                         IP.first.getBaseIndex());
       assert(UI != SA->UseSlots.begin() && "Couldn't find first use");
       SlotIndex Use = (--UI)->getBoundaryIndex();
       DEBUG(dbgs() << ", free use at " << *UI << ".\n");





More information about the llvm-commits mailing list