[llvm] [LAA] Add stencil group merging to reduce runtime pointer checks (PR #187252)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 05:24:50 PDT 2026
================
@@ -1098,11 +1128,18 @@ static std::pair<unsigned, unsigned> computeStencilMergeCost(
}
}
- // Each not-yet-committed positive-stride predicate becomes one extra runtime
- // check, so it counts against the saving.
+ // Charge once per stride, even when both limits need runtime predicates.
+ // Later DepSets can narrow an upper limit without adding another check.
+ const auto NeedsNewCheck = [&](const SCEV *Stride) {
+ return !StrideLowerLimits.contains(Stride) &&
+ !StrideUpperLimits.contains(Stride);
+ };
unsigned NewPredicates = 0;
- for (const SCEV *Stride : LocalStridesNeedingPreds)
- if (!CommittedStridePredicates.contains(Stride))
+ for (const SCEV *Stride : LocalStrideLowerLimits)
----------------
david-arm wrote:
This logic is quite complicated and hard to follow. Would it be simpler if we had a single `LocalStrideLimits` of the form:
```
const SmallMapVector<std::pair<const SCEV *, const SCEV *>, APInt, 4> LocalStrideLimits;
```
where the second element of the pair is nullptr if there is no upper limit? This way you only have to walk through one array.
https://github.com/llvm/llvm-project/pull/187252
More information about the llvm-commits
mailing list