[polly] [polly][tests] Fix loop index in C comments of tests with nested loops (PR #220589)

Timur Baidusenov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 07:12:42 PDT 2026


https://github.com/bai-tim updated https://github.com/llvm/llvm-project/pull/220589

>From 1a97094985daa407196c5a6776a45be280ec641a Mon Sep 17 00:00:00 2001
From: Timur Baidusenov <timurbaidusenov at gmail.com>
Date: Wed, 2 Sep 2026 13:09:22 +0000
Subject: [PATCH] [Polly][NFC] Fix loop index in C comments of tests with
 nested loops

The C pseudo-code in these tests declares `long i, j`, but the inner
loop reuses `i` instead of `j`, which would overwrite the outer loop
counter and describe a different program than the IR below it.

The IR indexes the store by the inner loop's phi node
(`getelementptr i64, ptr %A, i64 %indvar.j`), and the expected output in
the ScopInfo tests confirms this: the write access is
`MemRef_A[i1]` over the domain `Stmt_for_j[i0, i1]`, i.e. the second
(inner) dimension of the iteration space.

Rename the inner induction variable to `j` in the comments to match.
Comments only, no functional change.
---
 polly/test/ScopDetect/simple_loop_with_param.ll      | 10 +++++-----
 polly/test/ScopDetect/simple_loop_with_param_2.ll    |  4 ++--
 polly/test/ScopInfo/inter_bb_scalar_dep.ll           |  4 ++--
 polly/test/ScopInfo/intra_and_inter_bb_scalar_dep.ll |  4 ++--
 polly/test/ScopInfo/intra_bb_scalar_dep.ll           |  4 ++--
 polly/test/ScopInfo/tempscop-printing.ll             |  4 ++--
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/polly/test/ScopDetect/simple_loop_with_param.ll b/polly/test/ScopDetect/simple_loop_with_param.ll
index 67f677892313c..88fbb2296c3f5 100644
--- a/polly/test/ScopDetect/simple_loop_with_param.ll
+++ b/polly/test/ScopDetect/simple_loop_with_param.ll
@@ -2,14 +2,14 @@
 
 ; void f(long A[], long N, long *init_ptr) {
 ;   long i, j;
-;   long i_non_canonical;
+;   long j_non_canonical;
 ;
 ;   for (i = 0; i < N; ++i) {
 ;     init = *init_ptr;
-;     i_non_canonical = init;
-;     for (i = 0; i < N; ++i) {
-;       A[i] = i_non_canonical;
-;       i_non_canonical += 1;
+;     j_non_canonical = init;
+;     for (j = 0; j < N; ++j) {
+;       A[j] = j_non_canonical;
+;       j_non_canonical += 1;
 ;     }
 ;   }
 ; }
diff --git a/polly/test/ScopDetect/simple_loop_with_param_2.ll b/polly/test/ScopDetect/simple_loop_with_param_2.ll
index 9e7b55efc48d9..75accb82c6a18 100644
--- a/polly/test/ScopDetect/simple_loop_with_param_2.ll
+++ b/polly/test/ScopDetect/simple_loop_with_param_2.ll
@@ -5,8 +5,8 @@
 ;
 ;   for (i = 0; i < N; ++i) {
 ;     init = *init_ptr;
-;     for (i = 0; i < N; ++i) {
-;       A[i] = init + 2;
+;     for (j = 0; j < N; ++j) {
+;       A[j] = init + 2;
 ;     }
 ;   }
 ; }
diff --git a/polly/test/ScopInfo/inter_bb_scalar_dep.ll b/polly/test/ScopInfo/inter_bb_scalar_dep.ll
index f6406640dd2d8..4e207fb4afd09 100644
--- a/polly/test/ScopInfo/inter_bb_scalar_dep.ll
+++ b/polly/test/ScopInfo/inter_bb_scalar_dep.ll
@@ -5,8 +5,8 @@
 ;
 ;   for (i = 0; i < N; ++i) {
 ;     init = *init_ptr;
-;     for (i = 0; i < N; ++i) {
-;       A[i] = init + 2;
+;     for (j = 0; j < N; ++j) {
+;       A[j] = init + 2;
 ;     }
 ;   }
 ; }
diff --git a/polly/test/ScopInfo/intra_and_inter_bb_scalar_dep.ll b/polly/test/ScopInfo/intra_and_inter_bb_scalar_dep.ll
index b0b63658caa55..62e98a606eff5 100644
--- a/polly/test/ScopInfo/intra_and_inter_bb_scalar_dep.ll
+++ b/polly/test/ScopInfo/intra_and_inter_bb_scalar_dep.ll
@@ -5,9 +5,9 @@
 ;
 ;   for (i = 0; i < N; ++i) {
 ;     init = *init_ptr;
-;     for (i = 0; i < N; ++i) {
+;     for (j = 0; j < N; ++j) {
 ;       init2 = *init_ptr;
-;       A[i] = init + init2;
+;       A[j] = init + init2;
 ;     }
 ;   }
 ; }
diff --git a/polly/test/ScopInfo/intra_bb_scalar_dep.ll b/polly/test/ScopInfo/intra_bb_scalar_dep.ll
index 0ef6b2d35106b..b7746ae019b0e 100644
--- a/polly/test/ScopInfo/intra_bb_scalar_dep.ll
+++ b/polly/test/ScopInfo/intra_bb_scalar_dep.ll
@@ -4,9 +4,9 @@
 ;   long i, j;
 ;
 ;   for (i = 0; i < N; ++i) {
-;     for (i = 0; i < N; ++i) {
+;     for (j = 0; j < N; ++j) {
 ;       init = *init_ptr;
-;       A[i] = init + 2;
+;       A[j] = init + 2;
 ;     }
 ;   }
 ; }
diff --git a/polly/test/ScopInfo/tempscop-printing.ll b/polly/test/ScopInfo/tempscop-printing.ll
index 09cc95e42a584..58897ab37ac61 100644
--- a/polly/test/ScopInfo/tempscop-printing.ll
+++ b/polly/test/ScopInfo/tempscop-printing.ll
@@ -5,8 +5,8 @@
 ;
 ;   for (i = 0; i < N; ++i) {
 ;     init = *init_ptr;
-;     for (i = 0; i < N; ++i) {
-;       A[i] = init + 2;
+;     for (j = 0; j < N; ++j) {
+;       A[j] = init + 2;
 ;     }
 ;   }
 ; }



More information about the llvm-commits mailing list