[llvm] d24fe81 - ValueTracking: Look through canonicalize in isKnownNeverInfinity
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 17 00:06:21 PST 2022
Author: Matt Arsenault
Date: 2022-11-17T00:06:15-08:00
New Revision: d24fe812ecc149ee1897c73745ee09a3a26cf57c
URL: https://github.com/llvm/llvm-project/commit/d24fe812ecc149ee1897c73745ee09a3a26cf57c
DIFF: https://github.com/llvm/llvm-project/commit/d24fe812ecc149ee1897c73745ee09a3a26cf57c.diff
LOG: ValueTracking: Look through canonicalize in isKnownNeverInfinity
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 465678d08fc5..6f67509b8011 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3785,6 +3785,15 @@ bool llvm::isKnownNeverInfinity(const Value *V, const TargetLibraryInfo *TLI,
default:
break;
}
+
+ if (const auto *II = dyn_cast<IntrinsicInst>(V)) {
+ switch (II->getIntrinsicID()) {
+ case Intrinsic::canonicalize:
+ return isKnownNeverInfinity(Inst->getOperand(0), TLI, Depth + 1);
+ default:
+ break;
+ }
+ }
}
// try to handle fixed width vector constants
diff --git a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
index 7dc3842997b1..8ae5c51bbc72 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -185,6 +185,7 @@ declare <2 x float> @llvm.maxnum.v2f32(<2 x float>, <2 x float>)
declare float @llvm.maximum.f32(float, float)
declare double @llvm.exp2.f64(double)
declare float @llvm.fma.f32(float,float,float)
+declare double @llvm.canonicalize.f64(double)
declare void @expect_equal(i1,i1)
@@ -1261,3 +1262,24 @@ define i1 @isKnownNeverInfinity_fpext_sitofp(i16 %x) {
%r = fcmp oeq double %e, 0xfff0000000000000
ret i1 %r
}
+
+define i1 @isKnownNeverInfinity_canonicalize(double %x) {
+; CHECK-LABEL: @isKnownNeverInfinity_canonicalize(
+; CHECK-NEXT: ret i1 true
+;
+ %a = fadd ninf double %x, 1.0
+ %e = call double @llvm.canonicalize.f64(double %a)
+ %r = fcmp une double %e, 0x7ff0000000000000
+ ret i1 %r
+}
+
+define i1 @isNotKnownNeverInfinity_canonicalize(double %x) {
+; CHECK-LABEL: @isNotKnownNeverInfinity_canonicalize(
+; CHECK-NEXT: [[E:%.*]] = call double @llvm.canonicalize.f64(double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = fcmp une double [[E]], 0x7FF0000000000000
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %e = call double @llvm.canonicalize.f64(double %x)
+ %r = fcmp une double %e, 0x7ff0000000000000
+ ret i1 %r
+}
More information about the llvm-commits
mailing list