In the joiner, merge the small interval into the large interval. This restores
authorChris Lattner <sabre@nondot.org>
Sat, 24 Jul 2004 03:41:50 +0000 (03:41 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 24 Jul 2004 03:41:50 +0000 (03:41 +0000)
us back to taking about 10.5s on gcc, instead of taking 15.6s!  The net result
is that my big patches have hand no significant effect on compile time or code
quality.  heh.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15156 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveInterval.cpp

index 1cd9fb1a4a8ea1dbf8d3da7f032de3d3c8a2b112..79aa710c03b94f1564b0ec2543588444d2fb1488 100644 (file)
@@ -260,6 +260,15 @@ void LiveInterval::join(LiveInterval &Other, unsigned CopyIdx) {
   unsigned MergedSrcValIdx = SourceLR->ValId;
   unsigned MergedDstValIdx = DestLR->ValId;
 
+  // Try to do the least amount of work possible.  In particular, if there are
+  // more liverange chunks in the other set than there are in the 'this' set,
+  // swap sets to merge the fewest chunks in possible.
+  if (Other.ranges.size() > ranges.size()) {
+    std::swap(MergedSrcValIdx, MergedDstValIdx);
+    std::swap(ranges, Other.ranges);
+    std::swap(NumValues, Other.NumValues);
+  }
+
   // Join the ranges of other into the ranges of this interval.
   Ranges::iterator InsertPos = ranges.begin();
   std::map<unsigned, unsigned> Dst2SrcIdxMap;