float->int conversion rounds toward 0. Duh.

Fixes PR1698.

llvm-svn: 42273
This commit is contained in:
Dale Johannesen 2007-09-24 21:06:09 +00:00
parent bd8331da87
commit 5026f4ba93
1 changed files with 1 additions and 1 deletions

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