aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-04-09 23:29:07 +0000
committerChris Lattner <sabre@nondot.org>2007-04-09 23:29:07 +0000
commit9fda270e2ce31dafb29605612119242ffa838511 (patch)
treead17124854a82d22baf05b945e540bea3005866a
parentf7c83188cdef7f3c0a6f3921f5aa3dae3f559eed (diff)
eliminate the last uses of some TLI methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35844 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 91449ecb12..ccd44a22fe 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -536,11 +536,15 @@ static bool SinkInvariantGEPIndex(BinaryOperator *BinOp,
// Check if it is possible to fold the expression to address mode.
if (UseTy && isa<ConstantInt>(BinOp->getOperand(1))) {
- uint64_t Scale = TLI.getTargetData()->getTypeSize(UseTy);
int64_t Cst = cast<ConstantInt>(BinOp->getOperand(1))->getSExtValue();
// e.g. load (gep i32 * %P, (X+42)) => load (%P + X*4 + 168).
- if (TLI.isLegalAddressImmediate(Cst*Scale, UseTy) &&
- (Scale == 1 || TLI.isLegalAddressScale(Scale, UseTy))) {
+ TargetLowering::AddrMode AM;
+ // FIXME: This computation isn't right, scale is incorrect.
+ AM.Scale = TLI.getTargetData()->getTypeSize(UseTy);
+ // FIXME: Should should also include other fixed offsets.
+ AM.BaseOffs = Cst*AM.Scale;
+
+ if (TLI.isLegalAddressingMode(AM, UseTy)) {
DestBBs.insert(GEPIBB);
MadeChange = true;
break;