[llvm] dac496f - ValueTracking: Teach isKnownNeverInfinity about arithmetic.fence
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 5 05:39:14 PST 2022
Author: Matt Arsenault
Date: 2022-12-05T08:39:07-05:00
New Revision: dac496fb1f1d96a433311a30e62ff21319795a4e
URL: https://github.com/llvm/llvm-project/commit/dac496fb1f1d96a433311a30e62ff21319795a4e
DIFF: https://github.com/llvm/llvm-project/commit/dac496fb1f1d96a433311a30e62ff21319795a4e.diff
LOG: ValueTracking: Teach isKnownNeverInfinity about arithmetic.fence
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstSimplify/floating-point-compare.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 245942974a0f1..86c28ea1f7364 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3793,6 +3793,7 @@ bool llvm::isKnownNeverInfinity(const Value *V, const TargetLibraryInfo *TLI,
case Intrinsic::fabs:
case Intrinsic::canonicalize:
case Intrinsic::copysign:
+ case Intrinsic::arithmetic_fence:
return isKnownNeverInfinity(Inst->getOperand(0), TLI, Depth + 1);
default:
break;
diff --git a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
index 81bb0b9564ad4..62e063971d2a2 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -1347,3 +1347,26 @@ define i1 @isNotKnownNeverInfinity_copysign(double %x, double %sign) {
%r = fcmp une double %e, 0x7ff0000000000000
ret i1 %r
}
+
+define i1 @isKnownNeverInfinity_arithmetic_fence(double %x) {
+; CHECK-LABEL: @isKnownNeverInfinity_arithmetic_fence(
+; CHECK-NEXT: ret i1 true
+;
+ %a = fadd ninf double %x, 1.0
+ %e = call double @llvm.arithmetic.fence.f64(double %a)
+ %r = fcmp une double %e, 0x7ff0000000000000
+ ret i1 %r
+}
+
+define i1 @isNotKnownNeverInfinity_arithmetic_fence(double %x) {
+; CHECK-LABEL: @isNotKnownNeverInfinity_arithmetic_fence(
+; CHECK-NEXT: [[E:%.*]] = call double @llvm.arithmetic.fence.f64(double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = fcmp une double [[E]], 0x7FF0000000000000
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %e = call double @llvm.arithmetic.fence.f64(double %x)
+ %r = fcmp une double %e, 0x7ff0000000000000
+ ret i1 %r
+}
+
+declare double @llvm.arithmetic.fence.f64(double)
More information about the llvm-commits
mailing list