[llvm] [LoopInterchange] Supported partially-perfect Loop Nests (PR #199511)
Rohit Garg via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 15 05:20:34 PDT 2026
================
@@ -265,10 +273,16 @@ static bool populateDependencyMatrix(CharMatrix &DepMatrix, unsigned Level,
Dep.assign(Level, '*');
}
- while (Dep.size() != Level) {
+ while (Dep.size() < Level) {
----------------
rohgarg-qual wrote:
I think there is still a subtle alignment issue here when DA reports fewer levels than the full enclosing nest.
For example, consider:
```c++
// for (int i = 0; i < n; i++) { // Loop1
// for (int j = 0; j < m; j++) { // Loop2
// for (int r = 0; r < m; r++) // Loop3
// ...
// }
// }
and suppose the selected subnest is [Loop2, Loop3], so Level == 2.
My intention is to drop the direction corresponding to Loop1 and keep only the directions for [Loop2, Loop3].
The issue is the case where DA reports only two levels, e.g. Dep: [=, <]. Those two entries still correspond to the outermost common levels, i.e. [Loop1, Loop2], not [Loop2, Loop3].
If we hoist the trimming step above the padding step, then at that point:
- Dep.size() == 2
- Level == 2
so no trimming happens, and we keep [=, <] unchanged.
But for the selected subnest [Loop2, Loop3], what I actually want is:
- drop Loop1's direction
- keep Loop2's direction
- pad the missing Loop3 level as independent
which gives [<, I].
So hoisting the trim before the padding works if DA reports the full enclosing vector (for example [d1, d2, d3] -> [d2, d3]), but it does not seem sufficient when DA reports fewer levels, because then the remaining entries are still aligned to the outermost levels rather than to the selected subnest.
https://github.com/llvm/llvm-project/pull/199511
More information about the llvm-commits
mailing list