From 29178a348a719c4c4e14939dcc02218bcd5341d9 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Tue, 22 Jan 2013 09:46:31 +0000 Subject: Make APFloat constructor require explicit semantics. Previously we tried to infer it from the bit width size, with an added IsIEEE argument for the PPC/IEEE 128-bit case, which had a default value. This default value allowed bugs to creep in, where it was inappropriate. llvm-svn: 173138 --- llvm/lib/IR/ConstantFold.cpp | 8 ++++---- llvm/lib/IR/Constants.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'llvm/lib/IR') diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 0ffb24ee63f..417e0d14eb7 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -168,8 +168,8 @@ static Constant *FoldBitCast(Constant *V, Type *DestTy) { if (DestTy->isFloatingPointTy()) return ConstantFP::get(DestTy->getContext(), - APFloat(CI->getValue(), - !DestTy->isPPC_FP128Ty())); + APFloat(DestTy->getFltSemantics(), + CI->getValue())); // Otherwise, can't fold this (vector?) return 0; @@ -647,8 +647,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, case Instruction::SIToFP: if (ConstantInt *CI = dyn_cast(V)) { APInt api = CI->getValue(); - APFloat apf(APInt::getNullValue(DestTy->getPrimitiveSizeInBits()), - !DestTy->isPPC_FP128Ty() /* isEEEE */); + APFloat apf(DestTy->getFltSemantics(), + APInt::getNullValue(DestTy->getPrimitiveSizeInBits())); (void)apf.convertFromAPInt(api, opc==Instruction::SIToFP, APFloat::rmNearestTiesToEven); diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index e984aaca33b..8093a09749f 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -119,7 +119,8 @@ Constant *Constant::getNullValue(Type *Ty) { APFloat::getZero(APFloat::IEEEquad)); case Type::PPC_FP128TyID: return ConstantFP::get(Ty->getContext(), - APFloat(APInt::getNullValue(128))); + APFloat(APFloat::PPCDoubleDouble, + APInt::getNullValue(128))); case Type::PointerTyID: return ConstantPointerNull::get(cast(Ty)); case Type::StructTyID: -- cgit v1.2.3