[llvm] [LoopInterchange] Supported partially-perfect Loop Nests (PR #199511)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 01:28:48 PDT 2026


================
@@ -105,3 +126,124 @@ for.i.latch:
 exit:
   ret void
 }
+
+; This case shows a current limitation.
+;
+; collectPerfectNests() walks up from each innermost loop and stops as soon as
+; it reaches a loop with more than one subloop. But because [loop.i, loop.j] is never put in
+; any LoopList, the pass never analyses or attempts that interchange — the
+; opportunity is silently missed.
+;
+; Corresponding C code:
+;
+;   for (int i = 0; i < 8; ++i)
+;     for (int j = 0; j < 8; ++j) {
+;       A[i][j] = 0;                // missed: i/j interchange
+;       for (int k = 0; k < 8; ++k) {
+;         for (int l = 0; l < 8; ++l)
+;           for (int m = 0; m < 8; ++m)
+;             Left[m][l] = 0;       // interchanged: l/m swapped
+;         for (int n = 0; n < 8; ++n)
+;           for (int o = 0; o < 8; ++o)
+;             Right[o][n] = 0;      // interchanged: n/o swapped
+;       }
+;     }
+;
+
+define void @missed_outer_prefix_subnest(ptr noalias %Left, ptr noalias %Right,
----------------
kasuga-fj wrote:

Could you please move this test to a separate file? It's not a good idea to mix tests generated by UTC with tests that check debug messages in the same file.

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


More information about the llvm-commits mailing list