trunc to integer, not to FP.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32426 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-12-11 01:17:00 +00:00
parent d36a76d655
commit 509f85140c

View File

@ -660,8 +660,17 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
} else if (LI->getType()->isFloatingPoint()) {
// If needed, truncate the integer to the appropriate size.
if (NV->getType()->getPrimitiveSize() >
LI->getType()->getPrimitiveSize())
NV = new TruncInst(NV, LI->getType(), LI->getName(), LI);
LI->getType()->getPrimitiveSize()) {
switch (LI->getType()->getTypeID()) {
default: assert(0 && "Unknown FP type!");
case Type::FloatTyID:
NV = new TruncInst(NV, Type::UIntTy, LI->getName(), LI);
break;
case Type::DoubleTyID:
NV = new TruncInst(NV, Type::ULongTy, LI->getName(), LI);
break;
}
}
// Then do a bitcast.
NV = new BitCastInst(NV, LI->getType(), LI->getName(), LI);