Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions llvm/include/llvm/IR/Instructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CmpInst::Predicate>(NonStrictPredicate));
bool ProvedNonStrictComparison = false;
bool ProvedNonEquality = false;

Expand Down