summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 3b4e6031566..74468e8dd72 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1517,14 +1517,12 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
namespace {
Constant *GetConstantFoldFPValue(double V, Type *Ty) {
- if (Ty->isHalfTy()) {
+ if (Ty->isHalfTy() || Ty->isFloatTy()) {
APFloat APF(V);
bool unused;
- APF.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &unused);
+ APF.convert(Ty->getFltSemantics(), APFloat::rmNearestTiesToEven, &unused);
return ConstantFP::get(Ty->getContext(), APF);
}
- if (Ty->isFloatTy())
- return ConstantFP::get(Ty->getContext(), APFloat((float)V));
if (Ty->isDoubleTy())
return ConstantFP::get(Ty->getContext(), APFloat(V));
llvm_unreachable("Can only constant fold half/float/double");
OpenPOWER on IntegriCloud