[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Tue Jan 6 19:47:01 PST 2004
Changes in directory llvm/lib/CodeGen:
LiveIntervals.cpp updated: 1.18 -> 1.19
---
Log message:
Change implementation of LiveIntervals::overlap(). This results in a
30-50% decrease in running time of the linear scan register allocator.
---
Diffs of the changes: (+22 -10)
Index: llvm/lib/CodeGen/LiveIntervals.cpp
diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.18 llvm/lib/CodeGen/LiveIntervals.cpp:1.19
--- llvm/lib/CodeGen/LiveIntervals.cpp:1.18 Mon Jan 5 02:24:57 2004
+++ llvm/lib/CodeGen/LiveIntervals.cpp Tue Jan 6 19:45:58 2004
@@ -386,17 +386,29 @@
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;
More information about the llvm-commits
mailing list