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

            Bug ID: 93344
           Summary: interchange does not work when using the address
                    rather than direct array
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
#define N 100
#define M 1111
struct S { int a ; int b ; int c ; };
struct S A[N][M];

int __attribute__((noinline))
foo (void)
{
  int i, j;

  for( i = 0; i < M; i++)
    for( j = 0; j < N; j++)
     {
      struct S *a = A[j];
      a[i].b = 5 * a[i].b;
     }

  return A[0][0].b + A[N-1][M-1].b;
}

int __attribute__((noinline))
foo1 (void)
{
  int i, j;

  for( i = 0; i < M; i++)
    for( j = 0; j < N; j++)
     {
      A[j][i].b = 5 * A[j][i].b;
     }

  return A[0][0].b + A[N-1][M-1].b;
}

---- CUT ----
foo does not work but foo1 does work though.

Reply via email to