https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115697
Bug ID: 115697 Summary: Miscompilation with -fgraphite-identity at -O2 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: michael at orlitzky dot com Target Milestone: --- While debugging a test failure in the flint library (https://github.com/flintlib/flint/issues/2029), we seem to have discovered a miscompilation. Fredrik Johansson was able to come up with a minimal reproducer. This may be a duplicate of bug 47048, but having more reproducible test cases never hurts. $ gcc-15 -O2 -Wall -Wextra main.c $ ./a.out 6 4 1 $ gcc-15 -O2 -fgraphite-identity -Wall -Wextra main.c $ ./a.out 3 2 1 $ cat main.c #include <stdio.h> void shift(long * c, long n) { long i, j; if (n <= 62) { for (i = n - 2; i >= 0; i--) for (j = i; j < n - 1; j++) c[j] += c[j + 1]; } } int main(void) { long c[3]; volatile long n = 3; c[0] = 3; c[1] = 2; c[2] = 1; shift(c, n); printf("%ld %ld %ld\n", c[0], c[1], c[2]); }