diff options
author | Dale Johannesen <dalej@apple.com> | 2008-10-09 23:00:39 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2008-10-09 23:00:39 +0000 |
commit | 23a98551ab65eeb8fe5019df8b7db4891582a4bd (patch) | |
tree | 90d6731fd446c04df49383b8a23da0461337ba09 /lib/VMCore/ConstantFold.cpp | |
parent | 7111b02c734c992b8c97d9918118768026dad79e (diff) | |
download | external_llvm-23a98551ab65eeb8fe5019df8b7db4891582a4bd.zip external_llvm-23a98551ab65eeb8fe5019df8b7db4891582a4bd.tar.gz external_llvm-23a98551ab65eeb8fe5019df8b7db4891582a4bd.tar.bz2 |
Add a "loses information" return value to APFloat::convert
and APFloat::convertToInteger. Restore return value to
IEEE754. Adjust all users accordingly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57329 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 9256109..93ee7fe 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -213,13 +213,14 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, case Instruction::FPTrunc: case Instruction::FPExt: if (const ConstantFP *FPC = dyn_cast<ConstantFP>(V)) { + bool ignored; APFloat Val = FPC->getValueAPF(); Val.convert(DestTy == Type::FloatTy ? APFloat::IEEEsingle : DestTy == Type::DoubleTy ? APFloat::IEEEdouble : DestTy == Type::X86_FP80Ty ? APFloat::x87DoubleExtended : DestTy == Type::FP128Ty ? APFloat::IEEEquad : APFloat::Bogus, - APFloat::rmNearestTiesToEven); + APFloat::rmNearestTiesToEven, &ignored); return ConstantFP::get(Val); } return 0; // Can't fold. @@ -227,10 +228,11 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, case Instruction::FPToSI: if (const ConstantFP *FPC = dyn_cast<ConstantFP>(V)) { const APFloat &V = FPC->getValueAPF(); + bool ignored; uint64_t x[2]; uint32_t DestBitWidth = cast<IntegerType>(DestTy)->getBitWidth(); (void) V.convertToInteger(x, DestBitWidth, opc==Instruction::FPToSI, - APFloat::rmTowardZero); + APFloat::rmTowardZero, &ignored); APInt Val(DestBitWidth, 2, x); return ConstantInt::get(Val); } |