Skip to content

Commit 88f1a2f

Browse files
aqjunememfrob
authored andcommitted
[SCEV] Use logical and/or matcher
This is a minor patch that updates ScalarEvolution::isImpliedCond to use logical and/or matcher.
1 parent 0b2613b commit 88f1a2f

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10231,20 +10231,15 @@ bool ScalarEvolution::isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS,
1023110231
make_scope_exit([&]() { PendingLoopPredicates.erase(FoundCondValue); });
1023210232

1023310233
// Recursively handle And and Or conditions.
10234-
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(FoundCondValue)) {
10235-
if (BO->getOpcode() == Instruction::And) {
10236-
if (!Inverse)
10237-
return isImpliedCond(Pred, LHS, RHS, BO->getOperand(0), Inverse,
10238-
Context) ||
10239-
isImpliedCond(Pred, LHS, RHS, BO->getOperand(1), Inverse,
10240-
Context);
10241-
} else if (BO->getOpcode() == Instruction::Or) {
10242-
if (Inverse)
10243-
return isImpliedCond(Pred, LHS, RHS, BO->getOperand(0), Inverse,
10244-
Context) ||
10245-
isImpliedCond(Pred, LHS, RHS, BO->getOperand(1), Inverse,
10246-
Context);
10247-
}
10234+
const Value *Op0, *Op1;
10235+
if (match(FoundCondValue, m_LogicalAnd(m_Value(Op0), m_Value(Op1)))) {
10236+
if (!Inverse)
10237+
return isImpliedCond(Pred, LHS, RHS, Op0, Inverse, Context) ||
10238+
isImpliedCond(Pred, LHS, RHS, Op1, Inverse, Context);
10239+
} else if (match(FoundCondValue, m_LogicalOr(m_Value(Op0), m_Value(Op1)))) {
10240+
if (Inverse)
10241+
return isImpliedCond(Pred, LHS, RHS, Op0, Inverse, Context) ||
10242+
isImpliedCond(Pred, LHS, RHS, Op1, Inverse, Context);
1024810243
}
1024910244

1025010245
const ICmpInst *ICI = dyn_cast<ICmpInst>(FoundCondValue);

0 commit comments

Comments
 (0)