mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
Revert "[SCEV] Handle non-positive case in isImpliedViaOperations"
This reverts commit 8dc98897c4.
Commited by mistake.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user