Fix LiveInterval::overlaps so it doesn't claim touching intervals overlap.

Also, one binary search is enough.

llvm-svn: 108261
This commit is contained in:
Jakob Stoklund Olesen 2010-07-13 19:42:20 +00:00
parent 2ac1d3a2c9
commit 3726c5f775

View File

@ -161,16 +161,8 @@ bool LiveInterval::overlapsFrom(const LiveInterval& other,
/// by [Start, End). /// by [Start, End).
bool LiveInterval::overlaps(SlotIndex Start, SlotIndex End) const { bool LiveInterval::overlaps(SlotIndex Start, SlotIndex End) const {
assert(Start < End && "Invalid range"); assert(Start < End && "Invalid range");
const_iterator I = begin(); const_iterator I = std::lower_bound(begin(), end(), End);
const_iterator E = end(); return I != begin() && (--I)->end > Start;
const_iterator si = std::upper_bound(I, E, Start);
const_iterator ei = std::upper_bound(I, E, End);
if (si != ei)
return true;
if (si == I)
return false;
--si;
return si->contains(Start);
} }
/// extendIntervalEndTo - This method is used when we want to extend the range /// extendIntervalEndTo - This method is used when we want to extend the range