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)