[SCEV] Factor out a lambda for strict condition splitting [NFC]

This commit is contained in:
Philip Reames 2021-03-19 10:07:12 -07:00
parent 3bffa2c2aa
commit 00d0315a7c
1 changed files with 23 additions and 19 deletions

View File

@ -10028,13 +10028,23 @@ bool ScalarEvolution::isBasicBlockEntryGuardedByCond(const BasicBlock *BB,
bool ProvedNonStrictComparison = false;
bool ProvedNonEquality = false;
if (ProvingStrictComparison) {
ProvedNonStrictComparison =
isKnownViaNonRecursiveReasoning(NonStrictPredicate, LHS, RHS);
ProvedNonEquality =
isKnownViaNonRecursiveReasoning(ICmpInst::ICMP_NE, LHS, RHS);
auto SplitAndProve =
[&](std::function<bool(ICmpInst::Predicate)> Fn) -> bool {
if (!ProvedNonStrictComparison)
ProvedNonStrictComparison = Fn(NonStrictPredicate);
if (!ProvedNonEquality)
ProvedNonEquality = Fn(ICmpInst::ICMP_NE);
if (ProvedNonStrictComparison && ProvedNonEquality)
return true;
return false;
};
if (ProvingStrictComparison) {
auto ProofFn = [&](ICmpInst::Predicate P) {
return isKnownViaNonRecursiveReasoning(P, LHS, RHS);
};
if (SplitAndProve(ProofFn))
return true;
}
// Try to prove (Pred, LHS, RHS) using isImpliedViaGuard.
@ -10042,13 +10052,10 @@ bool ScalarEvolution::isBasicBlockEntryGuardedByCond(const BasicBlock *BB,
if (isImpliedViaGuard(Block, Pred, LHS, RHS))
return true;
if (ProvingStrictComparison) {
if (!ProvedNonStrictComparison)
ProvedNonStrictComparison =
isImpliedViaGuard(Block, NonStrictPredicate, LHS, RHS);
if (!ProvedNonEquality)
ProvedNonEquality =
isImpliedViaGuard(Block, ICmpInst::ICMP_NE, LHS, RHS);
if (ProvedNonStrictComparison && ProvedNonEquality)
auto ProofFn = [&](ICmpInst::Predicate P) {
return isImpliedViaGuard(Block, P, LHS, RHS);
};
if (SplitAndProve(ProofFn))
return true;
}
return false;
@ -10060,13 +10067,10 @@ bool ScalarEvolution::isBasicBlockEntryGuardedByCond(const BasicBlock *BB,
if (isImpliedCond(Pred, LHS, RHS, Condition, Inverse, Context))
return true;
if (ProvingStrictComparison) {
if (!ProvedNonStrictComparison)
ProvedNonStrictComparison = isImpliedCond(NonStrictPredicate, LHS, RHS,
Condition, Inverse, Context);
if (!ProvedNonEquality)
ProvedNonEquality = isImpliedCond(ICmpInst::ICMP_NE, LHS, RHS,
Condition, Inverse, Context);
if (ProvedNonStrictComparison && ProvedNonEquality)
auto ProofFn = [&](ICmpInst::Predicate P) {
return isImpliedCond(P, LHS, RHS, Condition, Inverse, Context);
};
if (SplitAndProve(ProofFn))
return true;
}
return false;