The following testcase:

===========================================
struct s{
  int m;
  int n[N][N][N];
};

struct test1{
  struct s a; /* array a.n is unaligned */
  int b;
  int c;
  struct s e[N]; /* array e.n is aligned */
};

int main ()
{
  int i,j;
  struct test1 tmp1;

  for (i = 0; i < N; i++)
    for (j = 3; j < N-3; j++)
      {
        tmp1.e[i].n[1][2][j] = 8;
      }

  /* check results:  */
  for (i = 0; i < N; i++)
    for (j = 3; j < N-3; j++)
    {
      if (tmp1.e[i].n[1][2][j] != 8)
          abort ();
    }

  /* not consecutive */
  for (i = 0; i < N; i++)
    for (j = 3; j < N-3; j++)
      {
        tmp1.e[j].n[1][2][j] = 8;
      }

  /* check results:  */
  for (i = 0; i < N; i++)
    for (j = 3; j < N-3; j++)
    {
      if (tmp1.e[j].n[1][2][j] != 8)
          abort ();
    }

  return 0;
}
===========================================

currently produces wrong results. The problem is that only the indexes of the 
last (rightmost) component are analyzed, and the rest are ignored, so we end up 
computing wrong alignment (for the first loop) and wrong step (for the second 
loop, where we conclude that the access is consecutive where it really isn't). 
Both these problems will be addressed soon by the patch that switches to use  
get_inner_reference (http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01140.html).

-- 
           Summary: vectorizer: wrong alignment/step/initial-address
                    computed for struct accesses
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: irar at il dot ibm dot com
        ReportedBy: dorit at il dot ibm dot com
                CC: dorit at il dot ibm dot com,gcc-bugs at gcc dot gnu dot
                    org
 GCC build triplet: powerpc-apple-darwin7.0.0
  GCC host triplet: powerpc-apple-darwin7.0.0
GCC target triplet: powerpc-apple-darwin7.0.0


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

Reply via email to