https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113787
--- Comment #12 from Alex Coplan <acoplan at gcc dot gnu.org> --- Here is an alternative testcase that also fails in the same way on the GCC 12 and 13 branches: void foo(int x, int y, int z, int d, int *buf) { for(int i = z; i < y-z; ++i) for(int j = 0; j < d; ++j) buf[i*x+(z-j-1)] = buf[i*x+(z+j)]; } void bar(int x, int y, int z, int d, int *buf) { for(int i = 0; i < d; ++i) for(int j = z; j < x-z; ++j) buf[j+(z-i-1)*x] = buf[j+(z+i)*x]; } __attribute__((noipa)) void baz(int x, int y, int d, int *buf) { foo(x, y, 0, d, buf); bar(x, y, 0, d, buf); } int main(void) { int a[] = { 1, 2, 3 }; baz (1, 2, 1, a+1); /* buf = a+1. foo does: buf[-1] = buf[0]; // { 2, 2, 3 } buf[0] = buf[1]; // { 2, 3, 3 } bar does: buf[-1] = buf[0]; // { 3, 3, 3 } */ for (int i = 0; i < 2; i++) if (a[i] != 3) __builtin_abort (); }