Skip to content

Commit

Permalink
ValueTracking: Update another cannotBeOrderedLessThanZero use
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenm committed Jul 7, 2023
1 parent 708fa7d commit 39f2fce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 8 additions & 4 deletions llvm/lib/Analysis/InstructionSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions llvm/test/Transforms/InstSimplify/floating-point-compare.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 39f2fce

Please sign in to comment.