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 | b67688a87cfc31f9da2d34b33a0c07632c789bfe (patch) | |
tree | 755fe02e50f87c669e51f88caf26f0b3066a432f /llvm/lib/Analysis | |
parent | 84c76ae6c7b41374278f9c96e13cdeb06b7b258f (diff) | |
download | bcm5719-llvm-b67688a87cfc31f9da2d34b33a0c07632c789bfe.tar.gz bcm5719-llvm-b67688a87cfc31f9da2d34b33a0c07632c789bfe.zip |
Allow constant folding of round function whenever feasible
llvm-svn: 203198
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index ff1124ad878..8ff79d6f625 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/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. |