diff options
author | Dan Gohman <gohman@apple.com> | 2009-03-13 02:25:09 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-03-13 02:25:09 +0000 |
commit | 77502c93442c5953c05e39fcd4c17d9e2aca766f (patch) | |
tree | cb356e11b4103eaa48e8040b8e0ca4df940075c0 /lib | |
parent | 990afedb3a4b7d32832d74ad5b5863c19f909e1f (diff) | |
download | external_llvm-77502c93442c5953c05e39fcd4c17d9e2aca766f.tar.gz external_llvm-77502c93442c5953c05e39fcd4c17d9e2aca766f.tar.bz2 external_llvm-77502c93442c5953c05e39fcd4c17d9e2aca766f.zip |
Enhance address-mode folding of ISD::ADD to handle cases where the
operands can't both be fully folded at the same time. For example,
in the included testcase, a global variable is being added with
an add of two values. The global variable wants RIP-relative
addressing, so it can't share the address with another base
register, but it's still possible to fold the initial add.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66865 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/X86/X86ISelDAGToDAG.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp index 855c890120..f81ab6f8a7 100644 --- a/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -907,6 +907,19 @@ bool X86DAGToDAGISel::MatchAddress(SDValue N, X86ISelAddressMode &AM, !MatchAddress(N.getNode()->getOperand(0), AM, false, Depth+1)) return false; AM = Backup; + + // If we couldn't fold both operands into the address at the same time, + // see if we can just put each operand into a register and fold at least + // the add. + if (AM.BaseType == X86ISelAddressMode::RegBase && + !AM.Base.Reg.getNode() && + !AM.IndexReg.getNode() && + !AM.isRIPRel) { + AM.Base.Reg = N.getNode()->getOperand(0); + AM.IndexReg = N.getNode()->getOperand(1); + AM.Scale = 1; + return false; + } break; } |