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

            Bug ID: 67700
           Summary: [graphite] miscompile due to wrong codegen
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hiraditya at msn dot com
  Target Milestone: ---

A reduced test case is below:
compile with trunk gcc: 

gcc -O2 -fgraphite-identity test.c
./a.out
int main(): Assertion `abcd->a[8] == 29' failed


struct abc {
  int a[81];
} *abcd;

#define FPMATH_SSE 2
int global;

void __attribute__ ((noinline)) foo()
{
   int pos = 0;
   int i;

   if (!((global & FPMATH_SSE) != 0)) 
        for (i = 8; i <= 15; i++)
          abcd->a[pos++] = i;

   for (i = 29; i <= 36; i++)
        abcd->a[pos++] = i;
}

#include <stdlib>
#include <stdio>
#include <assert>

int main()
{
  int i;
  abcd = (struct abc*) malloc (sizeof (abc));
  for (i = 0; i <= 80; i++)
    abcd->a[i] = 0;

  foo();

  assert (abcd->a[8] == 29);

  return 0;
}

Reply via email to