From: Chris Lattner Date: Wed, 11 Apr 2007 15:45:25 +0000 (+0000) Subject: Fix Transforms/ScalarRepl/union-pointer.ll X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=ab46275683ef76957619623d3dc9adeb33f9c08e;p=oota-llvm.git Fix Transforms/ScalarRepl/union-pointer.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35906 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index ad34012c45f..057bc6f5c9b 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1002,6 +1002,11 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { ConstantInt::get(Type::Int32Ty, Elt), "tmp", SI); } + } else if (isa(AllocaType)) { + // If the alloca type is a pointer, then all the elements must be + // pointers. + if (SV->getType() != AllocaType) + SV = new BitCastInst(SV, AllocaType, SV->getName(), SI); } else { Value *Old = new LoadInst(NewAI, NewAI->getName()+".in", SI); @@ -1013,12 +1018,8 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { if (SV->getType()->isFloatingPoint()) SV = new BitCastInst(SV, IntegerType::get(SrcWidth), SV->getName(), SI); - else if (isa(SV->getType())) { - if (isa(AllocaType)) - SV = new BitCastInst(SV, AllocaType, SV->getName(), SI); - else - SV = new PtrToIntInst(SV, TD.getIntPtrType(), SV->getName(), SI); - } + else if (isa(SV->getType())) + SV = new PtrToIntInst(SV, TD.getIntPtrType(), SV->getName(), SI); // Always zero extend the value if needed. if (SV->getType() != AllocaType)