[llvm] [Passes] Remove LoopInterchange from O1 pipeline (PR #145071)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 20 14:16:57 PDT 2025
kasuga-fj wrote:
By default, `LoopInterchange` prioritizes improving data locality over increasing vectorizable loops, which may lead to more contiguous memory accesses. I’m not very familiar with other simplification passes, but for example, such a transformation could make a loop eligible for replacement with `memcpy` or `memmove`.
That is, the following transformations could occur:
```c
// Original code
for (int j = 0; j < m; j++)
for (int i = 0; i < n; i++)
a[i][j] = b[i][j];
// LoopInterchange
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
a[i][j] = b[i][j];
// LoopIdiomRecognize
for (int i = 0; i < n; i++)
memcpy(a[i], b[i], m * sizeof(a[i][0]));
```
However, this is just a possibility, and I don't have a strong motivation to enhance other simplifications via loop interchange.
> IIRC there was a patch that added versioning support to DA
Maybe https://github.com/llvm/llvm-project/pull/123436 ? At the moment, DA only has the functionality to collect assumptions and versioning hasn't been implemented yet (though I assume it's something they intend to add in the future). IMHO, if it is allowed (e.g., low impact on compile time), it would be ideal to keep LoopInterchange in the simplification pipeline for data locality (while suppressing some features like versioning), and then add another instance in the optimization pipeline for vectorization.
https://github.com/llvm/llvm-project/pull/145071
More information about the llvm-commits
mailing list