float->int conversion rounds toward 0. Duh.
authorDale Johannesen <dalej@apple.com>
Mon, 24 Sep 2007 21:06:09 +0000 (21:06 +0000)
committerDale Johannesen <dalej@apple.com>
Mon, 24 Sep 2007 21:06:09 +0000 (21:06 +0000)
Fixes PR1698.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42273 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/ConstantFold.cpp

index 0c1d7f73ae1cec2b75f9470d9385f5f1d8002ae2..d8b8566193aedd95f6fe1d89844c8e443e1246fc 100644 (file)
@@ -196,7 +196,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
       uint32_t DestBitWidth = cast<IntegerType>(DestTy)->getBitWidth();
       APFloat::opStatus status = V.convertToInteger(x, DestBitWidth, 
                              opc==Instruction::FPToSI,
-                             APFloat::rmNearestTiesToEven);
+                             APFloat::rmTowardZero);
       if (status!=APFloat::opOK && status!=APFloat::opInexact)
         return 0; // give up
       APInt Val(DestBitWidth, 2, x);