aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2009-02-04 10:17:14 +0000
committerDuncan Sands <baldrick@free.fr>2009-02-04 10:17:14 +0000
commita06aef6ec55552640e45ffada96e43cae96cfc01 (patch)
tree6aecaeb4008b2c805ff1d92aeec1a4c77a4470c6
parent5caa883afc2c768c293757d4ca30d85b9094e876 (diff)
Fix PR3468: a crash when constant folding a bitcast of
i80 to x86 long double (this was presumably generated by sroa). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63730 91177308-0d34-0410-b5e6-96231b3b80d8
-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
+}