aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/ConstantFold.cpp11
-rw-r--r--test/Transforms/InstCombine/2009-02-04-FPBitcast.ll7
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 5c1578f74b..5f7cbcd0b6 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -153,12 +153,11 @@ static Constant *FoldBitCast(Constant *V, const Type *DestTy) {
// Integral -> Integral. This is a no-op because the bit widths must
// be the same. Consequently, we just fold to V.
return V;
-
- if (DestTy->isFloatingPoint()) {
- assert((DestTy == Type::DoubleTy || DestTy == Type::FloatTy) &&
- "Unknown FP type!");
- return ConstantFP::get(APFloat(CI->getValue()));
- }
+
+ if (DestTy->isFloatingPoint())
+ return ConstantFP::get(APFloat(CI->getValue(),
+ DestTy != Type::PPC_FP128Ty));
+
// Otherwise, can't fold this (vector?)
return 0;
}
diff --git a/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll b/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll
new file mode 100644
index 0000000000..4d7b70a115
--- /dev/null
+++ b/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-as < %s | opt -instcombine
+; PR3468
+
+define x86_fp80 @cast() {
+ %tmp = bitcast i80 0 to x86_fp80 ; <x86_fp80> [#uses=1]
+ ret x86_fp80 %tmp
+}