[llvm] [LAA] Compute pointer bounds for pattern with urem operation (PR #106574)
Sergey Kachkov via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 06:53:11 PDT 2024
================
@@ -809,9 +837,14 @@ class AccessAnalysis {
/// If \p Assume, try harder to prove that we can compute the bounds of \p Ptr
/// by adding run-time checks (overflow checks) if necessary.
static bool hasComputableBounds(PredicatedScalarEvolution &PSE, Value *Ptr,
- const SCEV *PtrScev, Loop *L, bool Assume) {
+ const SCEV *PtrScev, const Loop *L,
+ bool Assume) {
+ ScalarEvolution *SE = PSE.getSE();
// The bounds for loop-invariant pointer is trivial.
- if (PSE.getSE()->isLoopInvariant(PtrScev, L))
+ if (SE->isLoopInvariant(PtrScev, L))
+ return true;
+
+ if (getStartAndEndForURemAccess(*SE, PtrScev, L))
----------------
skachkov-sc wrote:
The main concern of moving URem logic below the AddRec handling is that the latter can use PredicatedScalarEvolution (when Assume = true) to match affine expressions, so we put more specialized URem case before attempting to add predicates here.
About the point of splitting getStartAndEndForURemAccess into two parts - I totally agree (will refactor it). But in general it seems that getStartAndEndForURemAccess() method repeats some checks of hasComputableBounds() method, and IMO the best solution is to unify these two functions (so that we check if bounds are computable and actually calculate them in one place).
https://github.com/llvm/llvm-project/pull/106574
More information about the llvm-commits
mailing list