[PATCH] D139319: ValueTracking: Teach isKnownNeverInfinity about llvm.log*
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 5 05:37:23 PST 2022
arsenm created this revision.
arsenm added reviewers: spatel, nlopes, jcranmer-intel, sepavloff, kpn, andrew.w.kaylor.
Herald added a subscriber: hiraditya.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
https://reviews.llvm.org/D139319
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstSimplify/floating-point-compare.ll
Index: llvm/test/Transforms/InstSimplify/floating-point-compare.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/floating-point-compare.ll
+++ llvm/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -1752,11 +1752,7 @@
define i1 @isKnownNeverInfinity_log(double %x) {
; CHECK-LABEL: @isKnownNeverInfinity_log(
-; CHECK-NEXT: [[X_CLAMP_ZERO:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double 0.000000e+00)
-; CHECK-NEXT: [[A:%.*]] = fadd ninf double [[X_CLAMP_ZERO]], 1.000000e+00
-; CHECK-NEXT: [[E:%.*]] = call double @llvm.log.f64(double [[A]])
-; CHECK-NEXT: [[R:%.*]] = fcmp une double [[E]], 0x7FF0000000000000
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 true
;
%x.clamp.zero = call double @llvm.maxnum.f64(double %x, double 0.0)
%a = fadd ninf double %x.clamp.zero, 1.0
@@ -1796,11 +1792,7 @@
define i1 @isKnownNeverInfinity_log10(double %x) {
; CHECK-LABEL: @isKnownNeverInfinity_log10(
-; CHECK-NEXT: [[X_CLAMP_ZERO:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double 0.000000e+00)
-; CHECK-NEXT: [[A:%.*]] = fadd ninf double [[X_CLAMP_ZERO]], 1.000000e+00
-; CHECK-NEXT: [[E:%.*]] = call double @llvm.log10.f64(double [[A]])
-; CHECK-NEXT: [[R:%.*]] = fcmp une double [[E]], 0x7FF0000000000000
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 true
;
%x.clamp.zero = call double @llvm.maxnum.f64(double %x, double 0.0)
%a = fadd ninf double %x.clamp.zero, 1.0
@@ -1840,11 +1832,7 @@
define i1 @isKnownNeverInfinity_log2(double %x) {
; CHECK-LABEL: @isKnownNeverInfinity_log2(
-; CHECK-NEXT: [[X_CLAMP_ZERO:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double 0.000000e+00)
-; CHECK-NEXT: [[A:%.*]] = fadd ninf double [[X_CLAMP_ZERO]], 1.000000e+00
-; CHECK-NEXT: [[E:%.*]] = call double @llvm.log2.f64(double [[A]])
-; CHECK-NEXT: [[R:%.*]] = fcmp une double [[E]], 0x7FF0000000000000
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 true
;
%x.clamp.zero = call double @llvm.maxnum.f64(double %x, double 0.0)
%a = fadd ninf double %x.clamp.zero, 1.0
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -3833,6 +3833,16 @@
case Intrinsic::maximum:
return isKnownNeverInfinity(Inst->getOperand(0), TLI, Depth + 1) &&
isKnownNeverInfinity(Inst->getOperand(1), TLI, Depth + 1);
+ case Intrinsic::log:
+ case Intrinsic::log10:
+ case Intrinsic::log2:
+ // log(+inf) -> +inf
+ // log([+-]0.0) -> -inf
+ // log(-inf) -> nan
+ // log(-x) -> nan
+ return isKnownNeverInfinity(Inst->getOperand(0), TLI, Depth + 1) &&
+ cannotBeOrderedLessThanZeroImpl(Inst->getOperand(0), TLI,
+ /*SignBitOnly=*/false, Depth + 1);
default:
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139319.480075.patch
Type: text/x-patch
Size: 3011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221205/900398fb/attachment.bin>
More information about the llvm-commits
mailing list