trunc to integer, not to FP.
authorChris Lattner <sabre@nondot.org>
Mon, 11 Dec 2006 01:17:00 +0000 (01:17 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 11 Dec 2006 01:17:00 +0000 (01:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32426 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/ScalarReplAggregates.cpp

index 4bdf6523a300ea7ecbc579fad6a2f0f8b31d0c84..764cda69e367c83e7c7d81648c750d258eecaeeb 100644 (file)
@@ -660,8 +660,17 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
           } else if (LI->getType()->isFloatingPoint()) {
             // If needed, truncate the integer to the appropriate size.
             if (NV->getType()->getPrimitiveSize() > 
-                  LI->getType()->getPrimitiveSize())
-              NV = new TruncInst(NV, LI->getType(), LI->getName(), LI);
+                LI->getType()->getPrimitiveSize()) {
+              switch (LI->getType()->getTypeID()) {
+              default: assert(0 && "Unknown FP type!");
+              case Type::FloatTyID:
+                NV = new TruncInst(NV, Type::UIntTy, LI->getName(), LI);
+                break;
+              case Type::DoubleTyID:
+                NV = new TruncInst(NV, Type::ULongTy, LI->getName(), LI);
+                break;
+              }
+            }
             
             // Then do a bitcast.
             NV = new BitCastInst(NV, LI->getType(), LI->getName(), LI);