In the following case #include <stdio.h> int a; int c[4][4]; void test_deps() { for (int i = 0; i <= 3; i++) { for (int j = 0; j <= 3; j++) { a ^= 0x1000; c[j][i] = a; } } } main() { test_deps(); for (int k = 0; k < 4; k++) printf("%d\n", c[0][k]); }
If we do the loop interchange, there will be correctness issues. However, the loop interchange can not be prevent by dependence matrix. The reason is that we have only one multi-dimensional array access c[j][i] within the loop, other accesses are scalar access. This patch is supposed to prevent loop interchange from the above case. We think the root cause of correctness issue is that the non-affine value (scalar) is stored to affine address (multi-dimensional array access).
This patch closes https://bugs.llvm.org/show_bug.cgi?id=47915
nit: re-flow comments