Fix Transforms/ConstProp/2007-02-05-BitCast.ll

llvm-svn: 33948
This commit is contained in:
Chris Lattner 2007-02-06 02:22:56 +00:00
parent ecb38495af
commit e62c89a9f5
1 changed files with 5 additions and 1 deletions

View File

@ -296,8 +296,12 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
// Handle ConstantFP input.
if (const ConstantFP *FP = dyn_cast<ConstantFP>(V)) {
// FP -> Integral.
if (DestTy->isInteger())
if (DestTy == Type::Int32Ty) {
return ConstantInt::get(DestTy, FloatToBits(FP->getValue()));
} else {
assert(DestTy == Type::Int64Ty && "only support f32/f64 for now!");
return ConstantInt::get(DestTy, DoubleToBits(FP->getValue()));
}
}
return 0;
default: