From 0cf64c94698e552b557e84d17c3a04063331c5ba Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Oct 2006 06:26:32 +0000 Subject: [PATCH] Fix Transforms/ScalarRepl/2006-10-23-PointerUnionCrash.ll llvm-svn: 31151 --- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 496449f4946..ffb095a0481 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -611,11 +611,16 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { NV = new ExtractElementInst(NV, ConstantInt::get(Type::UIntTy, Elt), "tmp", LI); } else { - assert(NV->getType()->isInteger() && "Unknown promotion!"); - if (Offset && Offset < TD.getTypeSize(NV->getType())*8) - NV = new ShiftInst(Instruction::Shr, NV, - ConstantInt::get(Type::UByteTy, Offset), - LI->getName(), LI); + if (Offset) { + assert(NV->getType()->isInteger() && "Unknown promotion!"); + if (Offset < TD.getTypeSize(NV->getType())*8) + NV = new ShiftInst(Instruction::Shr, NV, + ConstantInt::get(Type::UByteTy, Offset), + LI->getName(), LI); + } else { + assert((NV->getType()->isInteger() || + isa(NV->getType())) && "Unknown promotion!"); + } NV = new CastInst(NV, LI->getType(), LI->getName(), LI); } }