[llvm-commits] [llvm] r144772 - /llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp

Evan Cheng evan.cheng at apple.com
Tue Nov 15 19:47:42 PST 2011


Author: evancheng
Date: Tue Nov 15 21:47:42 2011
New Revision: 144772

URL: http://llvm.org/viewvc/llvm-project?rev=144772&view=rev
Log:
If the 2addr instruction has other kills, don't move it below any other uses since we don't want to extend other live ranges.

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

Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=144772&r1=144771&r2=144772&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original)
+++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Tue Nov 15 21:47:42 2011
@@ -933,6 +933,7 @@
     return false;
 
   SmallSet<unsigned, 2> Uses;
+  SmallSet<unsigned, 2> Kills;
   SmallSet<unsigned, 2> Defs;
   for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
     const MachineOperand &MO = MI->getOperand(i);
@@ -943,8 +944,11 @@
       continue;
     if (MO.isDef())
       Defs.insert(MOReg);
-    else
+    else {
       Uses.insert(MOReg);
+      if (MO.isKill() && MOReg != Reg)
+        Kills.insert(MOReg);
+    }
   }
 
   // Move the copies connected to MI down as well.
@@ -991,7 +995,8 @@
       } else {
         if (Defs.count(MOReg))
           return false;
-        if (MOReg != Reg && MO.isKill() && Uses.count(MOReg))
+        if (MOReg != Reg &&
+            ((MO.isKill() && Uses.count(MOReg)) || Kills.count(MOReg)))
           // Don't want to extend other live ranges and update kills.
           return false;
       }





More information about the llvm-commits mailing list