[llvm] [LoopInterchange] Do not interchange guarded imperfect loop nests (PR #201504)

Madhur Amilkanthwar via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 08:08:56 PDT 2026


================
@@ -8,13 +8,16 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 ;   int temp[16][16];
 ;   int res[16][16];
 ;   for(int i = 0; i < n; i++) {
-;     for(int j = 0; j < m; j++)
-;       res[j][i] = temp[j][i];
+;     if (m > 0)                  // guard: inner loop skipped when m <= 0
+;       for(int j = 0; j < m; j++)
+;         res[j][i] = temp[j][i];
 ;   }
 ; }
 
-;; This loop can be interchanged with -da-disable-delinearization-checks, otherwise it cannot
-;; be interchanged due to dependence.
+;; Not interchanged by default (dependence). Even with
+;; -da-disable-delinearization-checks it must not be: %outer.header runs the
+;; inner loop only when %cmp222 = (m > 0), and its exit (iv.next != m, nuw)
----------------
madhur13490 wrote:

Done

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


More information about the llvm-commits mailing list