[llvm-commits] [llvm] r63730 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/InstCombine/2009-02-04-FPBitcast.ll

Duncan Sands baldrick at free.fr
Wed Feb 4 02:17:20 PST 2009


Author: baldrick
Date: Wed Feb  4 04:17:14 2009
New Revision: 63730

URL: http://llvm.org/viewvc/llvm-project?rev=63730&view=rev
Log:
Fix PR3468: a crash when constant folding a bitcast of
i80 to x86 long double (this was presumably generated
by sroa).

Added:
    llvm/trunk/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll
Modified:
    llvm/trunk/lib/VMCore/ConstantFold.cpp

Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=63730&r1=63729&r2=63730&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Wed Feb  4 04:17:14 2009
@@ -153,12 +153,11 @@
       // 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;
   }

Added: llvm/trunk/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll?rev=63730&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll Wed Feb  4 04:17:14 2009
@@ -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
+}





More information about the llvm-commits mailing list