[llvm-commits] [llvm] r64823 - in /llvm/branches/Apple/Dib: lib/VMCore/ConstantFold.cpp test/Transforms/InstCombine/2009-02-04-FPBitcast.ll

Bill Wendling isanbard at gmail.com
Tue Feb 17 13:59:19 PST 2009


Author: void
Date: Tue Feb 17 15:59:18 2009
New Revision: 64823

URL: http://llvm.org/viewvc/llvm-project?rev=64823&view=rev
Log:
--- Merging (from foreign repository) r63730 into '.':
A    test/Transforms/InstCombine/2009-02-04-FPBitcast.ll
U    lib/VMCore/ConstantFold.cpp

Fix PR3468: a crash when constant folding a bitcast of
i80 to x86 long double (this was presumably generated
by sroa).

--- Merging (from foreign repository) r63731 into '.':
U    test/Transforms/InstCombine/2009-02-04-FPBitcast.ll
G    lib/VMCore/ConstantFold.cpp

Allow the inverse transform x86_fp80 -> i80 (also
fires during the Ada build).

--- Merging (from foreign repository) r63597 into '.':
A    test/Bitcode/extractelement.ll

fix a bitcode reader bug where it can't handle extractelement correctly:
the index of the value being extracted is always an i32.  This fixes PR3465

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

Modified: llvm/branches/Apple/Dib/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/VMCore/ConstantFold.cpp?rev=64823&r1=64822&r2=64823&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/branches/Apple/Dib/lib/VMCore/ConstantFold.cpp Tue Feb 17 15:59:18 2009
@@ -153,26 +153,20 @@
       // 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;
   }
-  
+
   // Handle ConstantFP input.
-  if (const ConstantFP *FP = dyn_cast<ConstantFP>(V)) {
+  if (const ConstantFP *FP = dyn_cast<ConstantFP>(V))
     // FP -> Integral.
-    if (DestTy == Type::Int32Ty) {
-      return ConstantInt::get(FP->getValueAPF().bitcastToAPInt());
-    } else {
-      assert(DestTy == Type::Int64Ty && "only support f32/f64 for now!");
-      return ConstantInt::get(FP->getValueAPF().bitcastToAPInt());
-    }
-  }
+    return ConstantInt::get(FP->getValueAPF().bitcastToAPInt());
+
   return 0;
 }
 

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

==============================================================================
--- llvm/branches/Apple/Dib/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll (added)
+++ llvm/branches/Apple/Dib/test/Transforms/InstCombine/2009-02-04-FPBitcast.ll Tue Feb 17 15:59:18 2009
@@ -0,0 +1,12 @@
+; 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
+}
+
+define i80 @invcast() {
+	%tmp = bitcast x86_fp80 0xK00000000000000000000 to i80		; <i80> [#uses=1]
+	ret i80 %tmp
+}





More information about the llvm-commits mailing list