From ab7ef35d3460762165be8b22eb2a07a808f8f828 Mon Sep 17 00:00:00 2001 From: Max Kazantsev Date: Thu, 5 Nov 2020 11:27:23 +0700 Subject: [PATCH] Revert "[SCEV] Handle non-positive case in isImpliedViaOperations" This reverts commit 8dc98897c4af20aeb52f1f19f538c08e55793283. Commited by mistake. --- llvm/lib/Analysis/ScalarEvolution.cpp | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index a385cd4..77fc2d4 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; -- 2.7.4