summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/VMCore/ConstantFolding.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/ConstantFolding.cpp b/llvm/lib/VMCore/ConstantFolding.cpp
index 41078d97f1d..a540f4e3944 100644
--- a/llvm/lib/VMCore/ConstantFolding.cpp
+++ b/llvm/lib/VMCore/ConstantFolding.cpp
@@ -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:
OpenPOWER on IntegriCloud