[llvm-commits] [llvm] r107376 - /llvm/trunk/lib/Target/X86/X86FastISel.cpp

Dan Gohman gohman at apple.com
Wed Jun 30 19:58:22 PDT 2010


Author: djg
Date: Wed Jun 30 21:58:21 2010
New Revision: 107376

URL: http://llvm.org/viewvc/llvm-project?rev=107376&view=rev
Log:
Fix X86FastISel's add folding to actually work, and not fall back
to SelectionDAG.

Modified:
    llvm/trunk/lib/Target/X86/X86FastISel.cpp

Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=107376&r1=107375&r2=107376&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Wed Jun 30 21:58:21 2010
@@ -430,6 +430,14 @@
           if (const ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
             // Constant-offset addressing.
             Disp += CI->getSExtValue() * S;
+          } else if (isa<AddOperator>(Op) &&
+                     isa<ConstantInt>(cast<AddOperator>(Op)->getOperand(1))) {
+            // An add with a constant operand. Fold the constant.
+            ConstantInt *CI =
+              cast<ConstantInt>(cast<AddOperator>(Op)->getOperand(1));
+            Disp += CI->getSExtValue() * S;
+            // Add the other operand back to the work list.
+            Worklist.push_back(cast<AddOperator>(Op)->getOperand(0));
           } else if (IndexReg == 0 &&
                      (!AM.GV || !Subtarget->isPICStyleRIPRel()) &&
                      (S == 1 || S == 2 || S == 4 || S == 8)) {
@@ -438,10 +446,6 @@
             IndexReg = getRegForGEPIndex(Op).first;
             if (IndexReg == 0)
               return false;
-          } else if (const AddOperator *Add = dyn_cast<AddOperator>(Op)) {
-            // An add. Try to fold both operands.
-            Worklist.push_back(Add->getOperand(0));
-            Worklist.push_back(Add->getOperand(1));
           } else
             // Unsupported.
             goto unsupported_gep;





More information about the llvm-commits mailing list