Only check if coalescing is worthwhile when the result is targeting a more restrictiv...
authorEvan Cheng <evan.cheng@apple.com>
Fri, 23 Jan 2009 05:48:59 +0000 (05:48 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 23 Jan 2009 05:48:59 +0000 (05:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62837 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SimpleRegisterCoalescing.cpp

index f0b0d58d13587969c01baf934457f10795bcdce8..f3ffc69cccbe5efffed6c6de78f4a66696b55f14 100644 (file)
@@ -1290,8 +1290,13 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
       }
     }
 
+    // If we are joining two virtual registers and the resulting register
+    // class is more restrictive (fewer register, smaller size). Check if it's
+    // worth doing the merge.
     if (!SrcIsPhys && !DstIsPhys &&
-        !isWinToJoinCrossClass(LargeReg, SmallReg, Limit)) {
+        (isExtSubReg || DstRC->isASubClass()) &&
+        !isWinToJoinCrossClass(LargeReg, SmallReg,
+                               allocatableRCRegs_[NewRC].count())) {
       DOUT << "\tSrc/Dest are different register classes.\n";
       // Allow the coalescer to try again in case either side gets coalesced to
       // a physical register that's compatible with the other side. e.g.