http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58248

            Bug ID: 58248
           Summary: wrong code at -O3 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

The current gcc trunk produces wrong code for the following testcase on
x86_64-linux when compiled at -O3 in both 32-bit and 64-bit modes. 

This is a regression from 4.8.x.


$ gcc-trunk -v
gcc version 4.9.0 20130826 (experimental) [trunk revision 201986] (GCC) 
$ gcc-trunk -O2 reduced.c
$ a.out
1
$ gcc-4.8 -O3 reduced.c
$ a.out
1
$ gcc-trunk -O3 reduced.c
$ a.out
0
$ 


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


int printf (const char *, ...);

struct S
{
  int u;
}; 

int a = 1, b, c = 1, e, *f, *g;

static struct S d = {6};

void foo (int *p)
{
  c &= a != *p;
}

int main ()
{
  struct S h = d;
  int **i = &f;
  *i = g = &b;
  for (; h.u; h.u--)
    {
      for (e = 0; e < 2; e++)
        {
      foo (*i);
      *g = 0 > **i;
        }
      *f = 0;
    }
  printf ("%d\n", c);
  return 0;
}

Reply via email to