[llvm] 84e64d9 - InstSimplify: Pass AssumptionCache to isKnownNeverNaN queries
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 16:48:14 PDT 2023
Author: Matt Arsenault
Date: 2023-05-19T00:48:03+01:00
New Revision: 84e64d9beeeaa6f783aa21cf7f0dd290e15ef408
URL: https://github.com/llvm/llvm-project/commit/84e64d9beeeaa6f783aa21cf7f0dd290e15ef408
DIFF: https://github.com/llvm/llvm-project/commit/84e64d9beeeaa6f783aa21cf7f0dd290e15ef408.diff
LOG: InstSimplify: Pass AssumptionCache to isKnownNeverNaN queries
Added:
Modified:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/floating-point-compare.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index ec3edcbd415e..3023b4459255 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4176,7 +4176,8 @@ static Value *simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
case FCmpInst::FCMP_ULT:
// Positive or zero X >= 0.0 --> true
// Positive or zero X < 0.0 --> false
- if ((FMF.noNaNs() || isKnownNeverNaN(LHS, Q.DL, Q.TLI)) &&
+ if ((FMF.noNaNs() ||
+ isKnownNeverNaN(LHS, Q.DL, Q.TLI, 0, Q.AC, Q.CxtI, Q.DT)) &&
CannotBeOrderedLessThanZero(LHS, Q.DL, Q.TLI))
return Pred == FCmpInst::FCMP_OGE ? getTrue(RetTy) : getFalse(RetTy);
break;
diff --git a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
index cc35c4832777..915e8afcd3ca 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -393,6 +393,34 @@ define i1 @fabs_fcmp-nnan_is_positive_or_zero(double %x) {
ret i1 %cmp
}
+define i1 @fabs_fcmp_oge0-assume-nnan_is_positive_or_zero(double %x) {
+; CHECK-LABEL: @fabs_fcmp_oge0-assume-nnan_is_positive_or_zero(
+; CHECK-NEXT: [[FABS:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])
+; CHECK-NEXT: [[ORD:%.*]] = fcmp ord double [[FABS]], 0.000000e+00
+; CHECK-NEXT: call void @llvm.assume(i1 [[ORD]])
+; CHECK-NEXT: ret i1 true
+;
+ %fabs = tail call double @llvm.fabs.f64(double %x)
+ %ord = fcmp ord double %fabs, 0.0
+ call void @llvm.assume(i1 %ord)
+ %cmp = fcmp oge double %fabs, 0.0
+ ret i1 %cmp
+}
+
+define i1 @fabs_fcmp_olt0_-assume-nnan_is_positive_or_zero(double %x) {
+; CHECK-LABEL: @fabs_fcmp_olt0_-assume-nnan_is_positive_or_zero(
+; CHECK-NEXT: [[FABS:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])
+; CHECK-NEXT: [[ORD:%.*]] = fcmp ord double [[FABS]], 0.000000e+00
+; CHECK-NEXT: call void @llvm.assume(i1 [[ORD]])
+; CHECK-NEXT: ret i1 false
+;
+ %fabs = tail call double @llvm.fabs.f64(double %x)
+ %ord = fcmp ord double %fabs, 0.0
+ call void @llvm.assume(i1 %ord)
+ %cmp = fcmp olt double %fabs, 0.0
+ ret i1 %cmp
+}
+
define <2 x i1> @fabs_fcmp-nnan_is_positive_or_zero_vec(<2 x double> %x) {
; CHECK-LABEL: @fabs_fcmp-nnan_is_positive_or_zero_vec(
; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
More information about the llvm-commits
mailing list