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

            Bug ID: 68321
           Summary: wrong code at -O3 on x86_64-linux-gnu (in 64-bit mode)
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The current gcc trunk (as well as 5.1.x and 5.2.x) miscompiles the following
code on x86_64-linux-gnu at -O3 in the 64-bit mode (but not in the 32-bit
mode). 

This is a regression from 4.9.x. 


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 6.0.0 20151111 (experimental) [trunk revision 230161] (GCC) 
$ 
$ gcc-trunk -m64 -O2 small.c; ./a.out
$ gcc-trunk -m32 -O3 small.c; ./a.out
$ gcc-4.9 -m64 -O3 small.c; ./a.out
$ 
$ gcc-trunk -m64 -O3 small.c      
$ ./a.out
Aborted (core dumped)
$ 
$ cat small.c
int e = 1, u = 5, t2, t5, i, k;
int a[1], b, m;
char n, t;

int
fn1 (int p1)
{
  int g[1];
  for (;;)
    {
      if (p1 / 3)
        for (; t5;)
          u || n;
      t2 = p1 & 4;
      if (b + 1)
        return 0;
      u = g[0];
    }
}

int
main ()
{
  for (; e >= 0; e--)
    {
      char c;
      if (!m)
        c = t;
      fn1 (c);
    }

  if (a[t2] != 0) 
    __builtin_abort (); 

  return 0;
}

Reply via email to