[llvm] [SCEV] Improve applyLoopGuards to support Mul (PR #83428)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 23:20:31 PST 2024


================
@@ -15208,11 +15212,8 @@ const SCEV *ScalarEvolution::applyLoopGuards(const SCEV *Expr, const Loop *L) {
             auto *MulRHS = Mul->getOperand(1);
             if (isa<SCEVConstant>(MulLHS))
               std::swap(MulLHS, MulRHS);
-            if (auto *Div = dyn_cast<SCEVUDivExpr>(MulLHS))
-              if (Div->getOperand(1) == MulRHS) {
-                DividesBy = MulRHS;
-                return true;
-              }
----------------
komalon1 wrote:

I see. This function only returns the candidate constant `DividesBy`.  Later on, we check if the whole SCEV `IsKnownToDivideBy` which queries `if (getURemExpr(Expr, DividesBy)->isZero())`. So I guess this SCEV utility will not return 0 if `X * constant` is not divisible by the constant.

https://github.com/llvm/llvm-project/pull/83428


More information about the llvm-commits mailing list