[llvm] [LAA] Compute pointer bounds for pattern with urem operation (PR #106574)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 06:00:49 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))
----------------
david-arm wrote:
Maybe it makes sense to add this extra code once we've failed to get the AddRec expression below? Also, it looks like you don't really need to call `getStartAndEndForURemAccess` here, since you don't require an actual SCEV expression at this point. For example, you could split `getStartAndEndForURemAccess` up into two parts - one to see if this is a valid urem access and the other to return the SCEV pair. Something like
```
getStartAndEndForURemAccess() {
if (!isValidURemAccess())
return std::nullopt;
...
}
hasComputableBounds() {
...
if (!AR)
return isValidURemAccess();
...
}
https://github.com/llvm/llvm-project/pull/106574
More information about the llvm-commits
mailing list