[llvm] [SCEV] Look thru more expressions in isKnownMultipleOf (PR #219951)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 06:58:44 PDT 2026
================
@@ -11330,6 +11321,29 @@ bool ScalarEvolution::isKnownMultipleOf(
if (!Predicates)
return false;
+ // Look through Add and AddRec expressions with nuw to improve the
+ // precision of added predicates. S is a multiple of M if S starts with a
+ // multiple of M and at every iteration step S only adds multiples of M.
+ if (isa<SCEVAddExpr, SCEVAddRecExpr>(S) &&
+ cast<SCEVNAryExpr>(S)->hasNoUnsignedWrap() &&
----------------
kasuga-fj wrote:
Side note: I don't object to this change, but in theory it may cause a regression in DA, since it only required `nsw` before. (I'm not sure whether an addrec with `nsw` but not `nuw` actually exists in practice.)
https://github.com/llvm/llvm-project/pull/219951
More information about the llvm-commits
mailing list