Fix constant folding of FP->int due to cut & paste error in last commit.

llvm-svn: 32447
This commit is contained in:
Reid Spencer 2006-12-11 21:27:28 +00:00
parent 3991c4af05
commit f48e2567ae

View File

@ -983,9 +983,10 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
if (const ConstantFP *FP = dyn_cast<ConstantFP>(V)) {
// FP -> Integral.
if (DestTy->isIntegral()) {
if (DestTy == Type::FloatTy)
if (DestTy == Type::IntTy || DestTy == Type::UIntTy)
return ConstantInt::get(DestTy, FloatToBits(FP->getValue()));
assert(DestTy == Type::DoubleTy && "Unknown FP type!");
assert((DestTy == Type::LongTy || DestTy == Type::ULongTy)
&& "Incorrect integer type for bitcast!");
return ConstantInt::get(DestTy, DoubleToBits(FP->getValue()));
}
}