summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2014-06-19 01:19:19 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2014-06-19 01:19:19 +0000
commitd9b35435b89015d154b0e20f4d4796d936237f84 (patch)
treec1fbe95a3f550edf4da38ffc64009b0063781697 /lib/Transforms
parentdd8406a6b7f0cbf9082c4bdb2cc8c3b3d5da6eec (diff)
downloadllvm-d9b35435b89015d154b0e20f4d4796d936237f84.tar.gz
llvm-d9b35435b89015d154b0e20f4d4796d936237f84.tar.bz2
llvm-d9b35435b89015d154b0e20f4d4796d936237f84.tar.xz
R600/SI: Add intrinsics for various math instructions.
These will be used for custom lowering and for library implementations of various math functions, so it's useful to expose these as builtins. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211247 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCalls.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp
index d4bdd75fa8..ff74564158 100644
--- a/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -922,6 +922,20 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
break;
}
+ case Intrinsic::AMDGPU_rcp: {
+ if (const ConstantFP *C = dyn_cast<ConstantFP>(II->getArgOperand(0))) {
+ const APFloat &ArgVal = C->getValueAPF();
+ APFloat Val(ArgVal.getSemantics(), 1.0);
+ APFloat::opStatus Status = Val.divide(ArgVal,
+ APFloat::rmNearestTiesToEven);
+ // Only do this if it was exact and therefore not dependent on the
+ // rounding mode.
+ if (Status == APFloat::opOK)
+ return ReplaceInstUsesWith(CI, ConstantFP::get(II->getContext(), Val));
+ }
+
+ break;
+ }
case Intrinsic::stackrestore: {
// If the save is right next to the restore, remove the restore. This can
// happen when variable allocas are DCE'd.