summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-02 21:29:13 +0000
committerDan Gohman <gohman@apple.com>2009-06-02 21:29:13 +0000
commit760377effc70dae9703211f7e45dac2fb73699fd (patch)
tree9bd2f64dce9ecd9f515e188ef6661c2f6098dfc2 /llvm/lib
parent6cbe978df2f58fe3637bbcdda8d50781a2ac56b8 (diff)
downloadbcm5719-llvm-760377effc70dae9703211f7e45dac2fb73699fd.tar.gz
bcm5719-llvm-760377effc70dae9703211f7e45dac2fb73699fd.zip
Fix CodeGenPrepare's address-mode sinking to handle unusual
addresses, involving Base values which do not have Pointer type. This fixes PR4297. llvm-svn: 72739
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 342b1e563d0..42978e753d1 100644
--- a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -624,8 +624,11 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
// Add in the base register.
if (AddrMode.BaseReg) {
Value *V = AddrMode.BaseReg;
- if (V->getType() != IntPtrTy)
+ if (isa<PointerType>(V->getType()))
V = new PtrToIntInst(V, IntPtrTy, "sunkaddr", InsertPt);
+ if (V->getType() != IntPtrTy)
+ V = CastInst::CreateIntegerCast(V, IntPtrTy, /*isSigned=*/true,
+ "sunkaddr", InsertPt);
if (Result)
Result = BinaryOperator::CreateAdd(Result, V, "sunkaddr", InsertPt);
else
OpenPOWER on IntegriCloud