float->int conversion rounds toward 0. Duh.

Fixes PR1698.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dale Johannesen 2007-09-24 21:06:09 +00:00
parent 189f80dc25
commit 6b92942c9c

View 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);