[llvm] [LAA] Allow zero-distance dependences between mixed-width accesses (PR #221531)
Hadong Lee via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 06:24:29 PDT 2026
ChrisLee02 wrote:
> Not sure about this: are we claiming that SzA * CommonStride can never overlap with SzB * CommonStride? Wouldn't this only be true at least if gcd(SzA, SzB) = 1? I don't think your Alive2 proof is exhaustive? I think something like #159534 shows a correct result?
I think this change covers a narrower case than the one considered in your comment, and relies on invariants established earlier in `getDependenceDistanceStrideAndSize`.
The relevant control flow in that function is:
```cpp
if (!StrideAPtrInt || !StrideBPtrInt) {
// ...
return MemoryDepChecker::Dependence::Unknown;
}
if ((StrideAPtrInt > 0) != (StrideBPtrInt > 0)) {
// ...
return MemoryDepChecker::Dependence::Unknown;
}
// ...
uint64_t StrideAScaled = AbsoluteValue(StrideAPtrInt) * ASz;
uint64_t StrideBScaled = AbsoluteValue(StrideBPtrInt) * BSz;
// ...
std::optional<uint64_t> CommonStride;
if (StrideAScaled == StrideBScaled)
CommonStride = StrideAScaled;
```
Thus, `S >= max(ASz, BSz)`. In the changed branch, `Dist == 0`, so both accesses start together and advance by `S`; since each fits within one stride, different iterations cannot overlap.
The Alive2 example covers the scope of this change: zero distance, a 4-byte load, an 8-byte store, and a common 8-byte stride. The regression tests exercise these conditions more concretely, including additional width and stride combinations as well as overlapping negative cases.
https://github.com/llvm/llvm-project/pull/221531
More information about the llvm-commits
mailing list