[llvm] [SCEV] Preserve divisibility info when creating UMax/SMax expressions. (PR #160012)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 8 12:52:01 PDT 2025


================
@@ -15746,6 +15746,11 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
     // DividesBy.
     std::function<bool(const SCEV *, const SCEV *&)> HasDivisibiltyInfo =
         [&](const SCEV *Expr, const SCEV *&DividesBy) {
+          const APInt &Multiple = SE.getConstantMultiple(Expr);
+          if (!Multiple.isOne()) {
+            DividesBy = SE.getConstant(Multiple);
+            return true;
+          }
----------------
nikic wrote:

Now that this function is no longer recursive, I think it would be cleaner to drop this lambda and inline it at the only usage.

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


More information about the llvm-commits mailing list