diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index 9a41971b63373..a1f964352207f 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -1231,6 +1231,18 @@ class ICmpInst: public CmpInst { return getSwappedCmpPredicate(getCmpPredicate()); } + /// @returns the non-strict predicate along with samesign information: static + /// variant. + static CmpPredicate getNonStrictCmpPredicate(CmpPredicate Pred) { + return {getNonStrictPredicate(Pred), Pred.hasSameSign()}; + } + + /// For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE. + /// @returns the non-strict predicate along with samesign information. + Predicate getNonStrictCmpPredicate() const { + return getNonStrictCmpPredicate(getCmpPredicate()); + } + /// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc. /// @returns the predicate that would be the result if the operand were /// regarded as signed. diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 0d7bbe3f99640..1673dc3acd2a1 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -11632,8 +11632,9 @@ bool ScalarEvolution::isBasicBlockEntryGuardedByCond(const BasicBlock *BB, // non-strict comparison is known from ranges and non-equality is known from // dominating predicates. If we are proving strict comparison, we always try // to prove non-equality and non-strict comparison separately. - auto NonStrictPredicate = ICmpInst::getNonStrictPredicate(Pred); - const bool ProvingStrictComparison = (Pred != NonStrictPredicate); + CmpPredicate NonStrictPredicate = ICmpInst::getNonStrictCmpPredicate(Pred); + const bool ProvingStrictComparison = + (Pred != static_cast(NonStrictPredicate)); bool ProvedNonStrictComparison = false; bool ProvedNonEquality = false;