Revert "[SCEV] Handle non-positive case in isImpliedViaOperations"

This reverts commit 8dc98897c4.

Commited by mistake.
This commit is contained in:
Max Kazantsev
2020-11-05 11:27:23 +07:00
parent f645cea8f6
commit ab7ef35d34

View File

@@ -10653,32 +10653,21 @@ bool ScalarEvolution::isImpliedViaOperations(ICmpInst::Predicate Pred,
}
// For unsigned, try to reduce it to corresponding signed comparison.
if (Pred == ICmpInst::ICMP_UGT) {
if (Pred == ICmpInst::ICMP_UGT)
// We can replace unsigned predicate with its signed counterpart if all
// involved values are non-negative or non-positive.
// involved values are non-negative.
// TODO: We could have better support for unsigned.
auto IsNonNegativeOrNonPositive = [this](const SCEV *S) {
return isKnownNonNegative(S) || isKnownNonPositive(S);
};
if (IsNonNegativeOrNonPositive(FoundLHS) &&
IsNonNegativeOrNonPositive(FoundRHS)) {
// Knowing that both FoundLHS and FoundRHS are non-negative/non-
// positive, and knowing FoundLHS >u FoundRHS, we also know that
// FoundLHS >s FoundRHS. Let us use this fact to prove that LHS and RHS
// are non-negative or non-positive.
const SCEV *One = getMinusOne(LHS->getType());
if (isKnownNonNegative(FoundLHS) && isKnownNonNegative(FoundRHS)) {
// Knowing that both FoundLHS and FoundRHS are non-negative, and knowing
// FoundLHS >u FoundRHS, we also know that FoundLHS >s FoundRHS. Let us
// use this fact to prove that LHS and RHS are non-negative.
const SCEV *MinusOne = getMinusOne(LHS->getType());
auto IsImpliedNonNegativeOrNonPositive = [&](const SCEV *S) {
return isImpliedCondOperands(ICmpInst::ICMP_SGT, S, MinusOne, FoundLHS,
FoundRHS) ||
isImpliedCondOperands(ICmpInst::ICMP_SGT, One, S, FoundLHS,
FoundRHS);
};
if (IsImpliedNonNegativeOrNonPositive(LHS) &&
IsImpliedNonNegativeOrNonPositive(RHS))
if (isImpliedCondOperands(ICmpInst::ICMP_SGT, LHS, MinusOne, FoundLHS,
FoundRHS) &&
isImpliedCondOperands(ICmpInst::ICMP_SGT, RHS, MinusOne, FoundLHS,
FoundRHS))
Pred = ICmpInst::ICMP_SGT;
}
}
if (Pred != ICmpInst::ICMP_SGT)
return false;