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

            Bug ID: 87176
           Summary: wrong code at -Os and above on x86-64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

It is a recent regression.

$ gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/home/su/software/tmp/gcc/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/home/su/software/tmp/gcc/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 9.0.0 20180831 (experimental) [trunk revision 264021] (GCC) 
$ 
$ gcctk -O1 small.c; ./a.out
$ gcc-8.1.0 -Os small.c; ./a.out
$ 
$ gcctk -Os small.c
$ timeout -s 9 5 ./a.out
Killed
$ 


------------------------------------------


int a, b, c;

int main ()
{
  int d = a = 0;
  while (1)
    {
      a = a ^ 6;
      if (!a)
        break;
      if (d)
        goto L;
      d = a;
      for (b = 0; b < 2; b++)
        {
          const int *f[3] = { &c };
          const int **g[] = { &f[2] };
          int h = ~d;
          if (d)
          L:
            if (h > 1)
              continue;
        }
    }
  return 0;
}

Reply via email to