forked from OSchip/llvm-project
[SCEV] Factor out a lambda for strict condition splitting [NFC]
This commit is contained in:
parent
3bffa2c2aa
commit
00d0315a7c
|
@ -10028,13 +10028,23 @@ bool ScalarEvolution::isBasicBlockEntryGuardedByCond(const BasicBlock *BB,
|
||||||
bool ProvedNonStrictComparison = false;
|
bool ProvedNonStrictComparison = false;
|
||||||
bool ProvedNonEquality = false;
|
bool ProvedNonEquality = false;
|
||||||
|
|
||||||
if (ProvingStrictComparison) {
|
auto SplitAndProve =
|
||||||
ProvedNonStrictComparison =
|
[&](std::function<bool(ICmpInst::Predicate)> Fn) -> bool {
|
||||||
isKnownViaNonRecursiveReasoning(NonStrictPredicate, LHS, RHS);
|
if (!ProvedNonStrictComparison)
|
||||||
ProvedNonEquality =
|
ProvedNonStrictComparison = Fn(NonStrictPredicate);
|
||||||
isKnownViaNonRecursiveReasoning(ICmpInst::ICMP_NE, LHS, RHS);
|
if (!ProvedNonEquality)
|
||||||
|
ProvedNonEquality = Fn(ICmpInst::ICMP_NE);
|
||||||
if (ProvedNonStrictComparison && ProvedNonEquality)
|
if (ProvedNonStrictComparison && ProvedNonEquality)
|
||||||
return true;
|
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.
|
// Try to prove (Pred, LHS, RHS) using isImpliedViaGuard.
|
||||||
|
@ -10042,13 +10052,10 @@ bool ScalarEvolution::isBasicBlockEntryGuardedByCond(const BasicBlock *BB,
|
||||||
if (isImpliedViaGuard(Block, Pred, LHS, RHS))
|
if (isImpliedViaGuard(Block, Pred, LHS, RHS))
|
||||||
return true;
|
return true;
|
||||||
if (ProvingStrictComparison) {
|
if (ProvingStrictComparison) {
|
||||||
if (!ProvedNonStrictComparison)
|
auto ProofFn = [&](ICmpInst::Predicate P) {
|
||||||
ProvedNonStrictComparison =
|
return isImpliedViaGuard(Block, P, LHS, RHS);
|
||||||
isImpliedViaGuard(Block, NonStrictPredicate, LHS, RHS);
|
};
|
||||||
if (!ProvedNonEquality)
|
if (SplitAndProve(ProofFn))
|
||||||
ProvedNonEquality =
|
|
||||||
isImpliedViaGuard(Block, ICmpInst::ICMP_NE, LHS, RHS);
|
|
||||||
if (ProvedNonStrictComparison && ProvedNonEquality)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -10060,13 +10067,10 @@ bool ScalarEvolution::isBasicBlockEntryGuardedByCond(const BasicBlock *BB,
|
||||||
if (isImpliedCond(Pred, LHS, RHS, Condition, Inverse, Context))
|
if (isImpliedCond(Pred, LHS, RHS, Condition, Inverse, Context))
|
||||||
return true;
|
return true;
|
||||||
if (ProvingStrictComparison) {
|
if (ProvingStrictComparison) {
|
||||||
if (!ProvedNonStrictComparison)
|
auto ProofFn = [&](ICmpInst::Predicate P) {
|
||||||
ProvedNonStrictComparison = isImpliedCond(NonStrictPredicate, LHS, RHS,
|
return isImpliedCond(P, LHS, RHS, Condition, Inverse, Context);
|
||||||
Condition, Inverse, Context);
|
};
|
||||||
if (!ProvedNonEquality)
|
if (SplitAndProve(ProofFn))
|
||||||
ProvedNonEquality = isImpliedCond(ICmpInst::ICMP_NE, LHS, RHS,
|
|
||||||
Condition, Inverse, Context);
|
|
||||||
if (ProvedNonStrictComparison && ProvedNonEquality)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue