[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:50 PDT 2024
================
@@ -190,6 +190,32 @@ RuntimeCheckingPtrGroup::RuntimeCheckingPtrGroup(
Members.push_back(Index);
}
+// Match expression in form of: PtrBase + (Dividend urem Divisor) * ConstStride,
+// where PtrBase and Divisor are loop-invariant and ConstStride is non-negative.
+// In this case Start = PtrBase, End = PtrBase + (Divisor - 1) * ConstStride.
+static std::optional<std::pair<const SCEV *, const SCEV *>>
+getStartAndEndForURemAccess(ScalarEvolution &SE, const SCEV *PtrScev,
+ const Loop *L) {
+ const SCEV *PtrBase = SE.getPointerBase(PtrScev);
+ if (!SE.isLoopInvariant(PtrBase, L))
+ return std::nullopt;
+ const SCEV *PtrAddend = SE.removePointerBase(PtrScev);
+ auto ConstStride = SE.getConstantMultiple(PtrAddend);
+ if (ConstStride.isNegative())
----------------
david-arm wrote:
Should we call `isStrictlyPositive` here instead so we avoid zero strides?
https://github.com/llvm/llvm-project/pull/106574
More information about the llvm-commits
mailing list