diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-03-30 22:28:26 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-03-30 22:28:26 +0000 |
commit | 5cd4f8f89fabe411445bb11c21add4fa7308e74b (patch) | |
tree | 4910a87b9252f4c1d6f35e3a0e290a1c21bb367b /llvm/lib/Transforms/InstCombine | |
parent | a8305830dbdc4122cf7e5c4e3257c7a93da12e1a (diff) | |
download | bcm5719-llvm-5cd4f8f89fabe411445bb11c21add4fa7308e74b.tar.gz bcm5719-llvm-5cd4f8f89fabe411445bb11c21add4fa7308e74b.zip |
AMDGPU: Constant folding for frexp_mant
llvm-svn: 264943
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 1de05dc89de..19d81fac778 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1846,6 +1846,20 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { break; } + case Intrinsic::amdgcn_frexp_mant: { + Value *Src = II->getArgOperand(0); + if (const ConstantFP *C = dyn_cast<ConstantFP>(Src)) { + int Exp; + APFloat Significand = frexp(C->getValueAPF(), Exp, + APFloat::rmNearestTiesToEven); + + return replaceInstUsesWith(CI, ConstantFP::get(II->getContext(), + Significand)); + } else if (isa<UndefValue>(Src)) + return replaceInstUsesWith(CI, Src); + + 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. |