[llvm-commits] [llvm] r129277 - /llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Apr 11 08:00:44 PDT 2011


Author: stoklund
Date: Mon Apr 11 10:00:44 2011
New Revision: 129277

URL: http://llvm.org/viewvc/llvm-project?rev=129277&view=rev
Log:
Speed up LiveIntervalUnion::unify by handling end insertion specially.

This particularly helps with the initial transfer of fixed intervals.

Modified:
    llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp

Modified: llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp?rev=129277&r1=129276&r2=129277&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp Mon Apr 11 10:00:44 2011
@@ -35,12 +35,20 @@
   LiveInterval::iterator RegEnd = VirtReg.end();
   SegmentIter SegPos = Segments.find(RegPos->start);
 
-  for (;;) {
+  while (SegPos.valid()) {
     SegPos.insert(RegPos->start, RegPos->end, &VirtReg);
     if (++RegPos == RegEnd)
       return;
     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.





More information about the llvm-commits mailing list