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

Evan Cheng evan.cheng at apple.com
Fri Jul 10 17:04:24 PDT 2009


Author: evancheng
Date: Fri Jul 10 19:04:23 2009
New Revision: 75317

URL: http://llvm.org/viewvc/llvm-project?rev=75317&view=rev
Log:
Two-address pass should use findCommutedOpIndices to determine what registers are commuted.

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=75317&r1=75316&r2=75317&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original)
+++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Fri Jul 10 19:04:23 2009
@@ -909,9 +909,16 @@
           }
 
           // If it's profitable to commute the instruction, do so.
-          if (TID.isCommutable() && mi->getNumOperands() >= 3) {
-            unsigned regC = mi->getOperand(3-si).getReg();
-            if (isProfitableToCommute(regB, regC, mi, mbbi, Dist))
+          unsigned SrcOp1, SrcOp2;
+          if (TID.isCommutable() && mi->getNumOperands() >= 3 &&
+              TII->findCommutedOpIndices(mi, SrcOp1, SrcOp2)) {
+            unsigned regC = 0;
+            if (si == SrcOp1)
+              regC = mi->getOperand(SrcOp2).getReg();
+            else if (si == SrcOp2)
+              regC = mi->getOperand(SrcOp1).getReg();
+            
+            if (regC && isProfitableToCommute(regB, regC, mi, mbbi, Dist))
               if (CommuteInstruction(mi, mbbi, regB, regC, Dist)) {
                 ++NumAggrCommuted;
                 ++NumCommuted;





More information about the llvm-commits mailing list