https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106315
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> --- Here is the testcase: --- void bar(int *indices, int max_iter, int *actual_indices, int *iters_per_dim, int N_dims) { int iter = 0; int sum_indices = 0; int flag, k; while (iter < max_iter) { for (k = N_dims - 1; k > 0; k--) { sum_indices += actual_indices[k]; } if (sum_indices >= max_iter) { return; } iter++; for (k = 0; k < N_dims; k++) { if (indices[k] < iters_per_dim[k] - 1) { indices[k]++; break; } } } } --- The second loop is unrolled after the commit.