[llvm] 39f2fce - ValueTracking: Update another cannotBeOrderedLessThanZero use
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 7 04:44:12 PDT 2023
Author: Matt Arsenault
Date: 2023-07-07T07:34:33-04:00
New Revision: 39f2fce0fa78b2503e18829a0818c27d7797d18e
URL: https://github.com/llvm/llvm-project/commit/39f2fce0fa78b2503e18829a0818c27d7797d18e
DIFF: https://github.com/llvm/llvm-project/commit/39f2fce0fa78b2503e18829a0818c27d7797d18e.diff
LOG: ValueTracking: Update another cannotBeOrderedLessThanZero use
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 b3abaf213b2e8d..aa8c179b114aa3 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4204,14 +4204,18 @@ static Value *simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
if (match(RHS, m_AnyZeroFP())) {
switch (Pred) {
case FCmpInst::FCMP_OGE:
- case FCmpInst::FCMP_ULT:
+ case FCmpInst::FCMP_ULT: {
+ FPClassTest Interested = FMF.noNaNs() ? fcNegative : fcNegative | fcNan;
+ KnownFPClass Known = computeKnownFPClass(LHS, Q.DL, Interested, 0,
+ Q.TLI, Q.AC, Q.CxtI, Q.DT);
+
// Positive or zero X >= 0.0 --> true
// Positive or zero X < 0.0 --> false
- if ((FMF.noNaNs() ||
- isKnownNeverNaN(LHS, Q.DL, Q.TLI, 0, Q.AC, Q.CxtI, Q.DT)) &&
- CannotBeOrderedLessThanZero(LHS, Q.DL, Q.TLI))
+ if ((FMF.noNaNs() || Known.isKnownNeverNaN()) &&
+ Known.cannotBeOrderedLessThanZero())
return Pred == FCmpInst::FCMP_OGE ? getTrue(RetTy) : getFalse(RetTy);
break;
+ }
case FCmpInst::FCMP_UGE:
case FCmpInst::FCMP_OLT:
// Positive or zero or nan X >= 0.0 --> true
diff --git a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
index 8ac2b341088cb0..2cdcdd82cf8e90 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -1478,8 +1478,7 @@ define i1 @fcmp_oge_0_assumed_oge_zero(float %x) {
; CHECK-LABEL: @fcmp_oge_0_assumed_oge_zero(
; CHECK-NEXT: [[ASSUME_CMP:%.*]] = fcmp oge float [[X:%.*]], 0.000000e+00
; CHECK-NEXT: call void @llvm.assume(i1 [[ASSUME_CMP]])
-; CHECK-NEXT: [[R:%.*]] = fcmp oge float [[X]], 0.000000e+00
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 true
;
%assume.cmp = fcmp oge float %x, 0.0
call void @llvm.assume(i1 %assume.cmp)
@@ -1491,8 +1490,7 @@ define i1 @fcmp_ult_0_assumed_oge_zero(float %x) {
; CHECK-LABEL: @fcmp_ult_0_assumed_oge_zero(
; CHECK-NEXT: [[ASSUME_CMP:%.*]] = fcmp oge float [[X:%.*]], 0.000000e+00
; CHECK-NEXT: call void @llvm.assume(i1 [[ASSUME_CMP]])
-; CHECK-NEXT: [[R:%.*]] = fcmp ult float [[X]], 0.000000e+00
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 false
;
%assume.cmp = fcmp oge float %x, 0.0
call void @llvm.assume(i1 %assume.cmp)
More information about the llvm-commits
mailing list