https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103615

            Bug ID: 103615
           Summary: [8/9 Regression] wrong code with "-O3" or "-O1
                    -ftree-vectorize" on x86_64-pc-linux-gnu
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: siarhei.siamashka at gmail dot com
  Target Milestone: ---

A reduced testcase from https://codeforces.com/blog/entry/97433

$ cat test.c
int z = 5;
int a[6] = {0, 0, 0, 0, 0, 1};
int main() {
  for (int x = 5; x; x--)
    for (int y = z; y >= x; y--)
      a[y - x] += a[y];
  if (a[0] != 7)
    __builtin_abort ();
  return 0;
}

$ gcc-7.3.0 -O3 test.c && ./a.out

$ gcc-8.3.0 -O3 test.c && ./a.out
Aborted

$ gcc-9.3.0 -O3 test.c && ./a.out
Aborted

$ gcc-9.4.1 -O3 test.c && ./a.out
Aborted

$ gcc-10.3.0 -O3 test.c && ./a.out

Only GCC versions 8.x and 9.x are affected and the bug is triggered by "-O3" or
"-O1 -ftree-vectorize" optimization option.

Reply via email to