[llvm] 3fc601b - [NFC][SCEV] Use generic predicate checkers to simplify code
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 29 04:12:52 PDT 2020
Author: Max Kazantsev
Date: 2020-10-29T18:12:28+07:00
New Revision: 3fc601b6416defd646142293797778c5d6652f14
URL: https://github.com/llvm/llvm-project/commit/3fc601b6416defd646142293797778c5d6652f14
DIFF: https://github.com/llvm/llvm-project/commit/3fc601b6416defd646142293797778c5d6652f14.diff
LOG: [NFC][SCEV] Use generic predicate checkers to simplify code
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 2911b2e424af..7a8d66438854 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -9274,13 +9274,15 @@ ScalarEvolution::getMonotonicPredicateTypeImpl(const SCEVAddRecExpr *LHS,
if (!ICmpInst::isRelational(Pred))
return None;
+ bool IsGreater = ICmpInst::isGE(Pred) || ICmpInst::isGT(Pred);
+ assert((IsGreater || ICmpInst::isLE(Pred) || ICmpInst::isLT(Pred)) &&
+ "Should be greater or less!");
+
// Check that AR does not wrap.
if (ICmpInst::isUnsigned(Pred)) {
if (!LHS->hasNoUnsignedWrap())
return None;
- return Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_UGE
- ? MonotonicallyIncreasing
- : MonotonicallyDecreasing;
+ return IsGreater ? MonotonicallyIncreasing : MonotonicallyDecreasing;
} else {
assert(ICmpInst::isSigned(Pred) &&
"Relational predicate is either signed or unsigned!");
@@ -9289,17 +9291,11 @@ ScalarEvolution::getMonotonicPredicateTypeImpl(const SCEVAddRecExpr *LHS,
const SCEV *Step = LHS->getStepRecurrence(*this);
- if (isKnownNonNegative(Step)) {
- return Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SGE
- ? MonotonicallyIncreasing
- : MonotonicallyDecreasing;
- }
+ if (isKnownNonNegative(Step))
+ return IsGreater ? MonotonicallyIncreasing : MonotonicallyDecreasing;
- if (isKnownNonPositive(Step)) {
- return Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SLE
- ? MonotonicallyIncreasing
- : MonotonicallyDecreasing;
- }
+ if (isKnownNonPositive(Step))
+ return !IsGreater ? MonotonicallyIncreasing : MonotonicallyDecreasing;
return None;
}
More information about the llvm-commits
mailing list