[llvm] [LoopInterchange] Relax legality check to accept `[* =]` or `[= *]` (PR #193480)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 02:29:30 PDT 2026
https://github.com/Meinersbur commented:
There is a problem with the justification.
> * Therefore, having [* =] should be almost equivalent to having [< =], [= =], and [> =].
This not entirely correct since `>` it not possible: `[> =]` would mean that there is a dependence from the future.
> * Among these, [> =] is normalized to [< =], so effectively we have [< =] and [= =], both of which pass the legality check.
It is swapped because we assume that the `Src` and `Dst` of `DependenceInfo::depends` have been passed in the wrong order. Again, because we know that an analysis result of `[> =]` is impossible. However, if the the result is `[* ...]`, such normalization cannot take place because it is not obviously in the wrong order, so we cannot argue with normalization.
Instead, I would argue with about the impossibility of `[> ...]` itself: If the first dependence vector entry is `*`, then it must actually be `<=` (which LoopInterchange cannot represent because for reasons that still puzzle me today, its a `char`, not a `DVEntry`). We could even integrate such a normalization into `FullDependence::normalize`.
This also means the logic of this PR can be improved: The loops do not need to be adjacent, we only need to conclude that the first `*` is actually a `<=`.
1. Interchanging `[... * ... =]` allows arbitatray `<=` between `*` and `=`. also `=` doesn't even need to be a `=`.
2. In `[... = ... *]`, all entries betwen `=` and `*` need to be `=` as well, or we could not conclude that the `*` is actually a `<=`.
https://github.com/llvm/llvm-project/pull/193480
More information about the llvm-commits
mailing list