Speed up LiveIntervalUnion::unify by handling end insertion specially.

This particularly helps with the initial transfer of fixed intervals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129277 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2011-04-11 15:00:44 +00:00
parent bd1926dfd4
commit 11983cd861

View File

@ -35,12 +35,20 @@ void LiveIntervalUnion::unify(LiveInterval &VirtReg) {
LiveInterval::iterator RegEnd = VirtReg.end(); LiveInterval::iterator RegEnd = VirtReg.end();
SegmentIter SegPos = Segments.find(RegPos->start); SegmentIter SegPos = Segments.find(RegPos->start);
for (;;) { while (SegPos.valid()) {
SegPos.insert(RegPos->start, RegPos->end, &VirtReg); SegPos.insert(RegPos->start, RegPos->end, &VirtReg);
if (++RegPos == RegEnd) if (++RegPos == RegEnd)
return; return;
SegPos.advanceTo(RegPos->start); SegPos.advanceTo(RegPos->start);
} }
// We have reached the end of Segments, so it is no longer necessary to search
// for the insertion position.
// It is faster to insert the end first.
--RegEnd;
SegPos.insert(RegEnd->start, RegEnd->end, &VirtReg);
for (; RegPos != RegEnd; ++RegPos, ++SegPos)
SegPos.insert(RegPos->start, RegPos->end, &VirtReg);
} }
// Remove a live virtual register's segments from this union. // Remove a live virtual register's segments from this union.