summaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveInterval.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-23 18:40:00 +0000
committerChris Lattner <sabre@nondot.org>2004-07-23 18:40:00 +0000
commitaa14147cd6401e9c66dc9f81d1a47a90a5477159 (patch)
tree537a7eee702b3c8ca4a9fb851539bfbd5b1ee2ca /lib/CodeGen/LiveInterval.cpp
parente6ad392802d8643ec7efad9bb80c0c429edda499 (diff)
downloadllvm-aa14147cd6401e9c66dc9f81d1a47a90a5477159.tar.gz
llvm-aa14147cd6401e9c66dc9f81d1a47a90a5477159.tar.bz2
llvm-aa14147cd6401e9c66dc9f81d1a47a90a5477159.tar.xz
Search by the start point, not by the whole interval. This saves some
comparisons, reducing linscan by another .1 seconds :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15139 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveInterval.cpp')
-rw-r--r--lib/CodeGen/LiveInterval.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp
index b0189daf83..25081e1f89 100644
--- a/lib/CodeGen/LiveInterval.cpp
+++ b/lib/CodeGen/LiveInterval.cpp
@@ -25,10 +25,10 @@ using namespace llvm;
// 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 @@ bool LiveInterval::liveAt(unsigned I) const {
return false;
--r;
- return I >= r->start && I < r->end;
+ return r->contains(I);
}
// An example for overlaps():
@@ -60,12 +60,13 @@ bool LiveInterval::overlaps(const LiveInterval& other) const {
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 @@ bool LiveInterval::overlaps(const LiveInterval& other) const {
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 @@ void LiveInterval::join(const LiveInterval& other) {
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;