@@ -15473,21 +15473,22 @@ void ScalarEvolution::LoopGuards::collectFromPHI(
1547315473 }
1547415474}
1547515475
15476- // Return a new SCEV that modifies \p Expr to the closest number divides by
15477- // \p Divisor and greater or equal than Expr. For now, only handle constant
15478- // Expr.
15476+ // Return a new SCEV that modifies \p Expr to the closest number divides by
15477+ // \p Divisor and greater or equal than Expr. For now, only handle constant
15478+ // Expr.
1547915479static const SCEV *getNextSCEVDividesByDivisor(const SCEV *Expr,
15480- const APInt &DivisorVal, ScalarEvolution &SE) {
15481- const APInt *ExprVal;
15482- if (!match(Expr, m_scev_APInt(ExprVal)) || ExprVal->isNegative() ||
15483- DivisorVal.isNonPositive())
15484- return Expr;
15485- APInt Rem = ExprVal->urem(DivisorVal);
15486- if (Rem.isZero())
15487- return Expr;
15488- // return the SCEV: Expr + Divisor - Expr % Divisor
15489- return SE.getConstant(*ExprVal + DivisorVal - Rem);
15490- }
15480+ const APInt &DivisorVal,
15481+ ScalarEvolution &SE) {
15482+ const APInt *ExprVal;
15483+ if (!match(Expr, m_scev_APInt(ExprVal)) || ExprVal->isNegative() ||
15484+ DivisorVal.isNonPositive())
15485+ return Expr;
15486+ APInt Rem = ExprVal->urem(DivisorVal);
15487+ if (Rem.isZero())
15488+ return Expr;
15489+ // return the SCEV: Expr + Divisor - Expr % Divisor
15490+ return SE.getConstant(*ExprVal + DivisorVal - Rem);
15491+ }
1549115492
1549215493void ScalarEvolution::LoopGuards::collectFromBlock(
1549315494 ScalarEvolution &SE, ScalarEvolution::LoopGuards &Guards,
@@ -15963,11 +15964,11 @@ const SCEV *ScalarEvolution::LoopGuards::rewrite(const SCEV *Expr) const {
1596315964 if (MatchBinarySub(S, LHS, RHS)) {
1596415965 if (LHS > RHS)
1596515966 std::swap(LHS, RHS);
15966- if (NotEqual.contains({LHS, RHS})){
15967+ if (NotEqual.contains({LHS, RHS})) {
1596715968 const SCEV *OneAlignedUp = getNextSCEVDividesByDivisor(
1596815969 SE.getOne(S->getType()), SE.getConstantMultiple(S), SE);
15969- return SE.getUMaxExpr(OneAlignedUp , S);
15970- }
15970+ return SE.getUMaxExpr(OneAlignedUp, S);
15971+ }
1597115972 }
1597215973 return nullptr;
1597315974 };
0 commit comments