1  /* { dg-require-effective-target vect_int } */
       2  /* { dg-add-options bind_pic_locally } */
       3  /* { dg-additional-options "--param vect-max-peeling-for-alignment=0" } */
       4  
       5  #include <stdarg.h>
       6  #include "tree-vect.h"
       7  
       8  #if VECTOR_BITS > 128
       9  #define NINTS (VECTOR_BITS / 32)
      10  #else
      11  #define NINTS 4
      12  #endif
      13  
      14  #define N (NINTS * 6)
      15  
      16  struct s{
      17    int m;
      18    int n[N][N][N];
      19  };
      20  
      21  struct s2{
      22    int m;
      23    int n[N-1][N-1][N-1];
      24  };
      25  
      26  struct test1{
      27    struct s a; /* array a.n is unaligned */
      28    int pad[NINTS - 2];
      29    struct s e; /* array e.n is aligned */
      30  };
      31  
      32  struct test2{
      33    struct s2 a; /* array a.n is unaligned */
      34    int b;
      35    int c;
      36    struct s2 e; /* array e.n is aligned */
      37  };
      38  
      39  
      40  struct test1 tmp1[4];
      41  struct test2 tmp2[4];
      42  
      43  __attribute__ ((noinline))
      44  int main1 ()
      45  {  
      46    int i,j;
      47  
      48    /* 1. unaligned (known misalignment) */
      49    for (i = 0; i < N; i++)
      50      {
      51        tmp1[2].a.n[1][2][i] = 5;
      52      }
      53  
      54    /* check results:  */
      55    for (i = 0; i <N; i++)
      56      {
      57        if (tmp1[2].a.n[1][2][i] != 5)
      58          abort ();
      59      }
      60  
      61    /* 2. aligned */
      62    for (i = NINTS - 1; i < N - 1; i++)
      63      {
      64        tmp1[2].a.n[1][2][i] = 6;
      65      }
      66  
      67    /* check results:  */
      68    for (i = NINTS; i < N - 1; i++)
      69      {
      70        if (tmp1[2].a.n[1][2][i] != 6)
      71          abort ();
      72      }
      73  
      74    /* 3. aligned */
      75    for (i = 0; i < N; i++)
      76      {
      77        for (j = 0; j < N; j++)
      78  	{
      79            tmp1[2].e.n[1][i][j] = 8;
      80  	}
      81      }
      82  
      83    /* check results:  */
      84    for (i = 0; i < N; i++)
      85      {
      86        for (j = 0; j < N; j++)
      87  	{
      88            if (tmp1[2].e.n[1][i][j] != 8)
      89  	    abort ();
      90  	}
      91      }
      92  
      93    /* 4. unaligned (unknown misalignment) */
      94    for (i = 0; i < N - NINTS; i++)
      95      {
      96        for (j = 0; j < N - NINTS; j++)
      97  	{
      98            tmp2[2].e.n[1][i][j] = 8;
      99  	}
     100      }
     101  
     102    /* check results:  */
     103    for (i = 0; i < N - NINTS; i++)
     104      {
     105        for (j = 0; j < N - NINTS; j++)
     106  	{
     107            if (tmp2[2].e.n[1][i][j] != 8)
     108  	    abort ();
     109  	}
     110      }
     111  
     112    return 0;
     113  }
     114  
     115  int main (void)
     116  { 
     117    check_vect ();
     118    
     119    return main1 ();
     120  } 
     121  
     122  /* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_hw_misalign } } } */
     123  /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { ! vect_hw_misalign } } } } */
     124  /* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { { ! vector_alignment_reachable } && { ! vect_hw_misalign } } } } } */