diff options
author | Karthik Bhat <kv.bhat@samsung.com> | 2014-03-07 04:36:21 +0000 |
---|---|---|
committer | Karthik Bhat <kv.bhat@samsung.com> | 2014-03-07 04:36:21 +0000 |
commit | 70957b9c55f13b962e01bf9214501f8b7e4b4459 (patch) | |
tree | 44ad2c4d4e835789f0db61a583c7b2bf5032eb9f /lib | |
parent | 40e107d960643d1ef104e483c34f046c86502911 (diff) | |
download | llvm-70957b9c55f13b962e01bf9214501f8b7e4b4459.tar.gz llvm-70957b9c55f13b962e01bf9214501f8b7e4b4459.tar.bz2 llvm-70957b9c55f13b962e01bf9214501f8b7e4b4459.tar.xz |
Allow constant folding of round function whenever feasible
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203198 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/ConstantFolding.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index ff1124ad87..8ff79d6f62 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -1196,6 +1196,7 @@ bool llvm::canConstantFoldCallTo(const Function *F) { case Intrinsic::fma: case Intrinsic::fmuladd: case Intrinsic::copysign: + case Intrinsic::round: case Intrinsic::sadd_with_overflow: case Intrinsic::uadd_with_overflow: case Intrinsic::ssub_with_overflow: @@ -1345,6 +1346,12 @@ static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, if (!Ty->isHalfTy() && !Ty->isFloatTy() && !Ty->isDoubleTy()) return 0; + if (IntrinsicID == Intrinsic::round) { + APFloat V = Op->getValueAPF(); + V.roundToIntegral(APFloat::rmNearestTiesToAway); + return ConstantFP::get(Ty->getContext(), V); + } + /// We only fold functions with finite arguments. Folding NaN and inf is /// likely to be aborted with an exception anyway, and some host libms /// have known errors raising exceptions. |