[llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Jul 23 11:40:10 PDT 2004



Changes in directory llvm/lib/CodeGen:

LiveInterval.cpp updated: 1.2 -> 1.3

---
Log message:

Search by the start point, not by the whole interval.  This saves some 
comparisons, reducing linscan by another .1 seconds :)


---
Diffs of the changes:  (+12 -11)

Index: llvm/lib/CodeGen/LiveInterval.cpp
diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.2 llvm/lib/CodeGen/LiveInterval.cpp:1.3
--- llvm/lib/CodeGen/LiveInterval.cpp:1.2	Fri Jul 23 13:13:24 2004
+++ llvm/lib/CodeGen/LiveInterval.cpp	Fri Jul 23 13:40:00 2004
@@ -25,10 +25,10 @@
 
 // An example for liveAt():
 //
-// this = [1,4), liveAt(0) will return false. The instruction defining
-// this spans slots [0,3]. The interval belongs to an spilled
-// definition of the variable it represents. This is because slot 1 is
-// used (def slot) and spans up to slot 3 (store slot).
+// this = [1,4), liveAt(0) will return false. The instruction defining this
+// spans slots [0,3]. The interval belongs to an spilled definition of the
+// variable it represents. This is because slot 1 is used (def slot) and spans
+// up to slot 3 (store slot).
 //
 bool LiveInterval::liveAt(unsigned I) const {
   Ranges::const_iterator r = std::upper_bound(ranges.begin(), ranges.end(), I);
@@ -37,7 +37,7 @@
     return false;
 
   --r;
-  return I >= r->start && I < r->end;
+  return r->contains(I);
 }
 
 // An example for overlaps():
@@ -60,12 +60,13 @@
   Ranges::const_iterator j = other.ranges.begin();
   Ranges::const_iterator je = other.ranges.end();
   if (i->start < j->start) {
-    i = std::upper_bound(i, ie, *j);
+    i = std::upper_bound(i, ie, j->start);
     if (i != ranges.begin()) --i;
-  }
-  else if (j->start < i->start) {
-    j = std::upper_bound(j, je, *i);
+  } else if (j->start < i->start) {
+    j = std::upper_bound(j, je, i->start);
     if (j != other.ranges.begin()) --j;
+  } else {
+    return true;
   }
 
   while (i != ie && j != je) {
@@ -88,7 +89,7 @@
 
 void LiveInterval::addRange(LiveRange LR) {
   Ranges::iterator it =
-    ranges.insert(std::upper_bound(ranges.begin(), ranges.end(), LR), LR);
+    ranges.insert(std::upper_bound(ranges.begin(), ranges.end(), LR.start), LR);
 
   mergeRangesBackward(mergeRangesForward(it));
 }
@@ -99,7 +100,7 @@
 
   for (Ranges::const_iterator i = other.ranges.begin(),
          e = other.ranges.end(); i != e; ++i) {
-    cur = ranges.insert(std::upper_bound(cur, ranges.end(), *i), *i);
+    cur = ranges.insert(std::upper_bound(cur, ranges.end(), i->start), *i);
     cur = mergeRangesBackward(mergeRangesForward(cur));
   }
   weight += other.weight;





More information about the llvm-commits mailing list