diff options
author | Dan Gohman <gohman@apple.com> | 2010-07-01 02:58:21 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-07-01 02:58:21 +0000 |
commit | 207624edb00cf2c29678b75c49f2d052556ec7ac (patch) | |
tree | 5fed7e1eb883051a2aeab68ec36353ce334d338e | |
parent | a7a0c835630e09a1353f0f946d0b93cef9d50383 (diff) | |
download | bcm5719-llvm-207624edb00cf2c29678b75c49f2d052556ec7ac.tar.gz bcm5719-llvm-207624edb00cf2c29678b75c49f2d052556ec7ac.zip |
Fix X86FastISel's add folding to actually work, and not fall back
to SelectionDAG.
llvm-svn: 107376
-rw-r--r-- | llvm/lib/Target/X86/X86FastISel.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index f371796141d..1c700b290a6 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -430,6 +430,14 @@ bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) { 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 @@ bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) { 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; |