------- Comment #9 from jakub at gcc dot gnu dot org  2008-04-23 16:35 -------
Even more simplified testcase, with just one CU.  Works at -O0/-O/-O2, fails at
-O{,2} -funroll-loops or -O3.
extern void abort (void);

void __attribute__ ((noinline))
bar (int m[3][3], int a[3][3], int b[3][3])
{
  int i, j;
  for (i = 0; i < 3; i++)
    for (j = 0; j < 3; j++)
      m[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
}

static inline void __attribute__ ((always_inline))
foo (int x[][3][3], int g[3][3], int y, int z)
{
  int i, j, k;
  for (i = 0; i < y; i++)
    for (j = 0; j < z - 1; j++)
      {
        k = i * (z - 1) + j + y;
        bar (x[k], g, x[k - y]);
      }
}

int g1[48][3][3] = { { {1, 0, 0}, {0, 1, 0}, {0, 0, 1} } };
int g2[3][3] = { {-1, 0, 0}, {0, -1, 0}, {0, 0, -1} };
int g3[3][3] = { {0, 1, 0}, {1, 0, 0}, {0, 0, 1} };
int g4[3][3] = { {-1, 0, 0}, {0, 1, 0}, {0, 0, -1} };
int g5[3][3] = { {-1, 0, 0}, {0, -1, 0}, {0, 0, 1} };

int
main ()
{
  foo (g1, g2, 1, 2);
  foo (g1, g4, 2, 2);
  foo (g1, g5, 4, 2);
  foo (g1, g3, 8, 2);
  if (g1[1][1][0] != 0)
    abort ();

  return 0;
}


-- 


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

Reply via email to