[all-commits] [llvm/llvm-project] a6a5bf: [LoopInterchange] Prevent interchange when memory-...
Ryotaro Kasuga via All-commits
all-commits at lists.llvm.org
Tue Jun 2 00:56:59 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a6a5bfc12f25de87815995d08e7d4f14477764ca
https://github.com/llvm/llvm-project/commit/a6a5bfc12f25de87815995d08e7d4f14477764ca
Author: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: 2026-06-02 (Tue, 02 Jun 2026)
Changed paths:
M llvm/lib/Transforms/Scalar/LoopInterchange.cpp
M llvm/test/Transforms/LoopInterchange/memory-attr.ll
Log Message:
-----------
[LoopInterchange] Prevent interchange when memory-accessing calls exist (#200828)
Previously loop-interchange can be applied even though the loop has call
instructions which may access the memory. The root cause of this problem
is that the implementation didn't match the comment, like below:
```cpp
// readnone functions do not prevent interchanging.
if (CI->onlyWritesMemory() || isa<PseudoProbeInst>(CI))
continue;
```
However, I think ensuring `readnone` is insufficient in the first place,
because the LLVM Language Reference states about `readnone` as follows:
```
This attribute indicates that the function does not dereference that pointer argument, even though it may read or write the memory that the pointer points to if accessed through other pointers.
```
So, this patch fixes the issue by verifying that all the calls in the
loop have the `memory(none)` attribute. We could probably check that all
the arguments of the calls have `readnone`, but I believe just calling
`doesNotAccessMemory` is simpler and sufficient in practical cases
(though I haven't actually checked).
Fixes #200796.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list