@@ -15749,38 +15749,11 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
1574915749 return RewriteMap.lookup_or(S, S);
1575015750 };
1575115751
15752- // Check for the SCEV expression (A /u B) * B while B is a constant, inside
15753- // \p Expr. The check is done recuresively on \p Expr, which is assumed to
15754- // be a composition of Min/Max SCEVs. Return whether the SCEV expression (A
15755- // /u B) * B was found, and return the divisor B in \p DividesBy. For
15756- // example, if Expr = umin (umax ((A /u 8) * 8, 16), 64), return true since
15757- // (A /u 8) * 8 matched the pattern, and return the constant SCEV 8 in \p
15758- // DividesBy.
15759- std::function<bool(const SCEV *, const SCEV *&)> HasDivisibiltyInfo =
15760- [&](const SCEV *Expr, const SCEV *&DividesBy) {
15761- const APInt &Multiple = SE.getConstantMultiple(Expr);
15762- if (!Multiple.isOne()) {
15763- DividesBy = SE.getConstant(Multiple);
15764- return true;
15765- }
15766- return false;
15767- };
15768-
15769- // Return true if Expr known to divide by \p DividesBy.
15770- std::function<bool(const SCEV *, const SCEV *&)> IsKnownToDivideBy =
15771- [&](const SCEV *Expr, const SCEV *DividesBy) {
15772- if (Expr->getType()->isIntegerTy() &&
15773- SE.getURemExpr(Expr, DividesBy)->isZero())
15774- return true;
15775- return false;
15776- };
15777-
1577815752 const SCEV *RewrittenLHS = GetMaybeRewritten(LHS);
1577915753 const SCEV *DividesBy = nullptr;
15780- if (HasDivisibiltyInfo(RewrittenLHS, DividesBy))
15781- // Check that the whole expression is divided by DividesBy
15782- DividesBy =
15783- IsKnownToDivideBy(RewrittenLHS, DividesBy) ? DividesBy : nullptr;
15754+ const APInt &Multiple = SE.getConstantMultiple(RewrittenLHS);
15755+ if (!Multiple.isOne())
15756+ DividesBy = SE.getConstant(Multiple);
1578415757
1578515758 // Collect rewrites for LHS and its transitive operands based on the
1578615759 // condition.
0 commit comments