[PATCH] D79413: [InstCombine] Allow denormal C in pow(C,y) -> exp2(log2(C)*y)
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 5 08:36:51 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22829ab5faf0: [InstCombine] Allow denormal C in pow(C,y) -> exp2(log2(C)*y) (authored by foad).
Changed prior to commit:
https://reviews.llvm.org/D79413?vs=262080&id=262124#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79413/new/
https://reviews.llvm.org/D79413
Files:
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/pow-exp.ll
Index: llvm/test/Transforms/InstCombine/pow-exp.ll
===================================================================
--- llvm/test/Transforms/InstCombine/pow-exp.ll
+++ llvm/test/Transforms/InstCombine/pow-exp.ll
@@ -263,8 +263,9 @@
define double @pow_ok_denorm_base(double %e) {
; CHECK-LABEL: @pow_ok_denorm_base(
-; CHECK-NEXT: [[CALL:%.*]] = tail call nnan ninf afn double @pow(double 0xFFFFFFFF, double [[E:%.*]])
-; CHECK-NEXT: ret double [[CALL]]
+; CHECK-NEXT: [[MUL:%.*]] = fmul nnan ninf afn double [[E:%.*]], 0xC0904800000005C5
+; CHECK-NEXT: [[EXP2:%.*]] = call nnan ninf afn double @exp2(double [[MUL]])
+; CHECK-NEXT: ret double [[EXP2]]
;
%call = tail call afn nnan ninf double @pow(double 0x00000000FFFFFFFF, double %e)
ret double %call
@@ -312,8 +313,9 @@
define float @powf_ok_denorm_base(float %e) {
; CHECK-LABEL: @powf_ok_denorm_base(
-; CHECK-NEXT: [[CALL:%.*]] = tail call nnan ninf afn float @powf(float 0x3780000000000000, float [[E:%.*]])
-; CHECK-NEXT: ret float [[CALL]]
+; CHECK-NEXT: [[MUL:%.*]] = fmul nnan ninf afn float [[E:%.*]], -1.350000e+02
+; CHECK-NEXT: [[EXP2F:%.*]] = call nnan ninf afn float @exp2f(float [[MUL]])
+; CHECK-NEXT: ret float [[EXP2F]]
;
%call = tail call afn nnan ninf float @powf(float 0x3780000000000000, float %e)
ret float %call
Index: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1565,7 +1565,7 @@
// pow(n, x) -> exp2(log2(n) * x)
if (Pow->hasApproxFunc() && Pow->hasNoNaNs() && Pow->hasNoInfs() &&
- BaseF->isNormal() && !BaseF->isNegative()) {
+ BaseF->isFiniteNonZero() && !BaseF->isNegative()) {
Value *Log = nullptr;
if (Ty->isFloatTy())
Log = ConstantFP::get(Ty, std::log2(BaseF->convertToFloat()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79413.262124.patch
Type: text/x-patch
Size: 1933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200505/f70fe2f3/attachment.bin>
More information about the llvm-commits
mailing list