[llvm] [LAA] Don't check same-address accesses against each other on retry (PR #226428)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 03:26:04 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Tim Besard (maleadt)

<details>
<summary>Changes</summary>

When LAA retries an unknown dependence with runtime checks, canCheckPtrAtRT removes the affected dependence classes, giving each pointer its own dependence set and checking group. This also separates safe dependences, including pointers accessing the same address each iteration, such as stores to A[i] in both branches of an if. Their identical bounds make the runtime check always fail, so the vector loop never runs.

Regroup accesses whose pointers have the same AddRec in the loop, whose loads and stores all have the same type, and whose stride is one element. They access the same bytes each iteration and disjoint bytes across iterations, so their only dependence has distance 0, preserved by vectorization. Consecutive accesses cannot join an interleave group that could reorder them, which matters because the retry discarded those dependences. Sharing a checking group also removes duplicate checks against other accesses.

Only the retry changes, after which recorded dependences are cleared. LoopLoadElimination and other passes relying on checks between classes while dependences are available are unaffected.

Motivation: Julia stores `Union{Float32, Nothing}` array values and type tags in one allocation, with tags at a runtime offset. Copy loops were vectorized with an always-failing check. In a reduced X86 test, memchecks drop from 7 comparisons (including `tags < tags_end` against itself) to 4, letting the vector loop run: 0.33 -> 0.07 ns/element on Zen 5 (n = 10000).

Assisted by: Codex 5.5, Astra 6
Part of a series of patches developed while migrating Julia to LLVM 23

---
Full diff: https://github.com/llvm/llvm-project/pull/226428.diff


4 Files Affected:

- (modified) llvm/lib/Analysis/LoopAccessAnalysis.cpp (+36) 
- (added) llvm/test/Analysis/LoopAccessAnalysis/retry-runtime-checks-same-address.ll (+338) 
- (modified) llvm/test/Analysis/LoopAccessAnalysis/runtime-checks-max-dependences.ll (+122) 
- (added) llvm/test/Transforms/LoopVectorize/X86/runtime-checks-same-address.ll (+120) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````

</details>


https://github.com/llvm/llvm-project/pull/226428


More information about the llvm-commits mailing list