[llvm] ab7ef35 - Revert "[SCEV] Handle non-positive case in isImpliedViaOperations"
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 4 20:28:16 PST 2020
Author: Max Kazantsev
Date: 2020-11-05T11:27:55+07:00
New Revision: ab7ef35d3460762165be8b22eb2a07a808f8f828
URL: https://github.com/llvm/llvm-project/commit/ab7ef35d3460762165be8b22eb2a07a808f8f828
DIFF: https://github.com/llvm/llvm-project/commit/ab7ef35d3460762165be8b22eb2a07a808f8f828.diff
LOG: Revert "[SCEV] Handle non-positive case in isImpliedViaOperations"
This reverts commit 8dc98897c4af20aeb52f1f19f538c08e55793283.
Commited by mistake.
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index a385cd4e8dc2..77fc2d47785d 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -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;
More information about the llvm-commits
mailing list