diff options
author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-01-07 01:45:58 +0000 |
---|---|---|
committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-01-07 01:45:58 +0000 |
commit | 1e01557c4e43ffbc6cd869b4fdcb71602476336e (patch) | |
tree | 151633d7f9570fa56ba8b2ad18223f6a7e0eee93 /llvm/lib/CodeGen/LiveIntervals.cpp | |
parent | bd2977be1ad4b1ffcedfaade226d3cc723d9ea7f (diff) | |
download | bcm5719-llvm-1e01557c4e43ffbc6cd869b4fdcb71602476336e.tar.gz bcm5719-llvm-1e01557c4e43ffbc6cd869b4fdcb71602476336e.zip |
Change implementation of LiveIntervals::overlap(). This results in a
30-50% decrease in running time of the linear scan register allocator.
llvm-svn: 10707
Diffstat (limited to 'llvm/lib/CodeGen/LiveIntervals.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveIntervals.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp index 1bd8deb37b2..fe47a3661d8 100644 --- a/llvm/lib/CodeGen/LiveIntervals.cpp +++ b/llvm/lib/CodeGen/LiveIntervals.cpp @@ -386,17 +386,29 @@ bool LiveIntervals::Interval::liveAt(unsigned index) const bool LiveIntervals::Interval::overlaps(const Interval& other) const { - std::vector<bool> bitMap(end(), false); - for (Ranges::const_iterator r = ranges.begin(); r != ranges.end(); ++r) { - for (unsigned i = r->first; i < r->second; ++i) - bitMap[i] = true; - } - for (Ranges::const_iterator r = other.ranges.begin(); - r != other.ranges.end(); ++r) { - for (unsigned i = r->first; - i < r->second && i < bitMap.size(); ++i) - if (bitMap[i]) + Ranges::const_iterator i = ranges.begin(); + Ranges::const_iterator j = other.ranges.begin(); + + while (i != ranges.end() && j != other.ranges.end()) { + if (i->first < j->first) { + if (i->second > j->first) { + return true; + } + else { + ++i; + } + } + else if (j->first < i->first) { + if (j->second > i->first) { return true; + } + else { + ++j; + } + } + else { + return true; + } } return false; |