aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2004-01-07 01:45:58 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2004-01-07 01:45:58 +0000
commit80b378cf7c3dce77029dc3118e1f63bc6d389da1 (patch)
treee1491dd927b9776854ce490b549f5a53f11918bd /lib
parentf6608ddf449d8c3d37d70732b85cc41fd8ff36da (diff)
downloadexternal_llvm-80b378cf7c3dce77029dc3118e1f63bc6d389da1.zip
external_llvm-80b378cf7c3dce77029dc3118e1f63bc6d389da1.tar.gz
external_llvm-80b378cf7c3dce77029dc3118e1f63bc6d389da1.tar.bz2
Change implementation of LiveIntervals::overlap(). This results in a
30-50% decrease in running time of the linear scan register allocator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10707 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index 1bd8deb..fe47a36 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.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;