[llvm] [LoopInterchange] Relax legality check to accept `[* =]` or `[= *]` (PR #193480)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 2 03:47:08 PDT 2026


Meinersbur wrote:

> > Instead, I would argue with about the impossibility of `[> ...]` itself: If the first dependence vector entry is `*`, then it must actually be `<=`
> 
> Thanks for the clarification. I believe I understand your argument, and it looks sound to me. Just to confirm, your suggestion is to replace the first `*` with `<=`, right?

This is one possibility to extend the normalization, yes. But that would probably be a larger refactor which would not be a condition for my approval; just fix the summary and source comments. 



> > 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 ``<=``.
> > ```
> 
> If I understand correctly, these points are naturally addressed by replacing the first `*` with `<=` ?

Yes.

Consider my EDIT of my previous post. The argument only applies of we know the dependence vector is in the "correct order". Some cases:
 * '[< * ...]': Is in correct order because lexicographic positive. `*` cannot be replaced with `<=` because it actually can be `>` since the `<` already ensures positivity
 * '[> * ...]'. same as above after normalization
 * `[= * =]`: `*` can be assumed to be `<=` because it is symmetric
 * `[= * >]`: we do not know whether Src and Dst are in correct order. `*` could be a `>` in which case it would have been normalized. However, for interchanging the first and second loop, the third entry doesn't matter: if the dependence was legal before, it will also be legal after interchanging `=` and `*`
 * `[= * <]`: same as above
 * `[* * =]`: symmetric, so the first `*` must be `<=`, but the second can be anything


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


More information about the llvm-commits mailing list