[llvm] b00209e - [SCEV] Use logical and/or matcher
Juneyoung Lee via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 22 14:01:06 PDT 2021
Author: Juneyoung Lee
Date: 2021-03-23T06:00:54+09:00
New Revision: b00209ed100cf76acca2e7f8c8ae511658fe4816
URL: https://github.com/llvm/llvm-project/commit/b00209ed100cf76acca2e7f8c8ae511658fe4816
DIFF: https://github.com/llvm/llvm-project/commit/b00209ed100cf76acca2e7f8c8ae511658fe4816.diff
LOG: [SCEV] Use logical and/or matcher
This is a minor patch that updates ScalarEvolution::isImpliedCond to use logical and/or matcher.
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index e8f0e242ef42..2cc6362e870e 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -10231,20 +10231,15 @@ bool ScalarEvolution::isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS,
make_scope_exit([&]() { PendingLoopPredicates.erase(FoundCondValue); });
// Recursively handle And and Or conditions.
- if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(FoundCondValue)) {
- if (BO->getOpcode() == Instruction::And) {
- if (!Inverse)
- return isImpliedCond(Pred, LHS, RHS, BO->getOperand(0), Inverse,
- Context) ||
- isImpliedCond(Pred, LHS, RHS, BO->getOperand(1), Inverse,
- Context);
- } else if (BO->getOpcode() == Instruction::Or) {
- if (Inverse)
- return isImpliedCond(Pred, LHS, RHS, BO->getOperand(0), Inverse,
- Context) ||
- isImpliedCond(Pred, LHS, RHS, BO->getOperand(1), Inverse,
- Context);
- }
+ const Value *Op0, *Op1;
+ if (match(FoundCondValue, m_LogicalAnd(m_Value(Op0), m_Value(Op1)))) {
+ if (!Inverse)
+ return isImpliedCond(Pred, LHS, RHS, Op0, Inverse, Context) ||
+ isImpliedCond(Pred, LHS, RHS, Op1, Inverse, Context);
+ } else if (match(FoundCondValue, m_LogicalOr(m_Value(Op0), m_Value(Op1)))) {
+ if (Inverse)
+ return isImpliedCond(Pred, LHS, RHS, Op0, Inverse, Context) ||
+ isImpliedCond(Pred, LHS, RHS, Op1, Inverse, Context);
}
const ICmpInst *ICI = dyn_cast<ICmpInst>(FoundCondValue);
More information about the llvm-commits
mailing list