diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-01-11 06:36:20 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-01-11 06:36:20 +0000 |
| commit | b74ec4cd249c5e9d2c74b15799e4175168b64f87 (patch) | |
| tree | 60238985b27bf088e567b4044ce88cc81df15db1 /llvm/lib | |
| parent | 4596db350981d1582ffffca3b0626e60d991e64d (diff) | |
| download | bcm5719-llvm-b74ec4cd249c5e9d2c74b15799e4175168b64f87.tar.gz bcm5719-llvm-b74ec4cd249c5e9d2c74b15799e4175168b64f87.zip | |
Instead of generating stuff like this:
mov %ECX, %EAX
add %ECX, 32768
mov %SI, WORD PTR [2*%ECX + l13_prev]
Generate this:
mov %SI, WORD PTR [2*%ECX + l13_prev + 65536]
This occurs when you have a GEP instruction where an index is
"something + imm".
llvm-svn: 19472
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelPattern.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86ISelPattern.cpp b/llvm/lib/Target/X86/X86ISelPattern.cpp index 8073342895a..40e4c414ff9 100644 --- a/llvm/lib/Target/X86/X86ISelPattern.cpp +++ b/llvm/lib/Target/X86/X86ISelPattern.cpp @@ -429,7 +429,20 @@ bool ISel::SelectAddress(SDOperand N, X86AddressMode &AM) { unsigned Val = CN->getValue(); if (Val == 1 || Val == 2 || Val == 3) { AM.Scale = 1 << Val; - AM.IndexReg = SelectExpr(N.Val->getOperand(0)); + SDOperand ShVal = N.Val->getOperand(0); + + // Okay, we know that we have a scale by now. However, if the scaled + // value is an add of something and a constant, we can fold the + // constant into the disp field here. + if (ShVal.Val->getOpcode() == ISD::ADD && + isa<ConstantSDNode>(ShVal.Val->getOperand(1))) { + AM.IndexReg = SelectExpr(ShVal.Val->getOperand(0)); + ConstantSDNode *AddVal = + cast<ConstantSDNode>(ShVal.Val->getOperand(1)); + AM.Disp += AddVal->getValue() << Val; + } else { + AM.IndexReg = SelectExpr(ShVal); + } return false; } } |

