Avoid deleting extra copies when RegistersDefinedFromSameValue is true.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 20 May 2012 04:52:48 +0000 (04:52 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 20 May 2012 04:52:48 +0000 (04:52 +0000)
This function adds copies to be erased to DupCopies, avoid also adding
them to DeadCopies.

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

lib/CodeGen/RegisterCoalescer.cpp

index f529f1899ca4d57bfdc85361372d19332867b4aa..149b6b751f9b51aa218691cc5a4b9b10e286a6a8 100644 (file)
@@ -1310,9 +1310,10 @@ bool RegisterCoalescer::joinIntervals(CoalescerPair &CP) {
 
     // DstReg is known to be a register in the LHS interval.  If the src is
     // from the RHS interval, we can use its value #.
-    if (!CP.isCoalescable(MI) &&
-        !RegistersDefinedFromSameValue(*LIS, *TRI, CP, VNI, OtherVNI,
-                                       DupCopies))
+    if (CP.isCoalescable(MI))
+      DeadCopies.push_back(MI);
+    else if (!RegistersDefinedFromSameValue(*LIS, *TRI, CP, VNI, OtherVNI,
+                                            DupCopies))
       continue;
 
     LHSValsDefinedFromRHS[VNI] = OtherVNI;
@@ -1339,13 +1340,13 @@ bool RegisterCoalescer::joinIntervals(CoalescerPair &CP) {
 
     // DstReg is known to be a register in the RHS interval.  If the src is
     // from the LHS interval, we can use its value #.
-    if (!CP.isCoalescable(MI) &&
-        !RegistersDefinedFromSameValue(*LIS, *TRI, CP, VNI, OtherVNI,
-                                       DupCopies))
+    if (CP.isCoalescable(MI))
+      DeadCopies.push_back(MI);
+    else if (!RegistersDefinedFromSameValue(*LIS, *TRI, CP, VNI, OtherVNI,
+                                            DupCopies))
         continue;
 
     RHSValsDefinedFromLHS[VNI] = OtherVNI;
-    DeadCopies.push_back(MI);
   }
 
   LHSValNoAssignments.resize(LHS.getNumValNums(), -1);