From 760377effc70dae9703211f7e45dac2fb73699fd Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 2 Jun 2009 21:29:13 +0000 Subject: 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 --- llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp') 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(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 -- cgit v1.2.3