1  /* { dg-require-effective-target vect_float } */
       2  
       3  #include <stdarg.h>
       4  #include "tree-vect.h"
       5  
       6  #define N 64
       7  #define MAX 42
       8  
       9  extern void abort(void); 
      10  
      11  __attribute__ ((noinline)) 
      12  int main1 ()
      13  {  
      14    float A[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      15    float B[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      16    float C[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      17    float D[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      18    float E[4] = {0,480,960,1440};
      19    float s;
      20  
      21    int i, j;
      22  
      23    for (i = 0; i < N; i++)
      24      {
      25        A[i] = i;
      26        B[i] = i;
      27        C[i] = i;
      28        D[i] = i;
      29      }
      30  
      31    /* Outer-loop 1: Vectorizable with respect to dependence distance. */
      32    for (i = 0; i < N-20; i++)
      33      {
      34        s = 0;
      35        for (j=0; j<N; j+=4)
      36          s += C[j];
      37        A[i] = A[i+20] + s;
      38      }
      39  
      40    /* check results:  */
      41    for (i = 0; i < N-20; i++)
      42      {
      43        s = 0;
      44        for (j=0; j<N; j+=4)
      45          s += C[j];
      46        if (A[i] != D[i+20] + s)
      47          abort ();
      48      }
      49  
      50    /* Outer-loop 2: Not vectorizable because of dependence distance. */
      51    for (i = 0; i < 4; i++)
      52      {
      53        s = 0;
      54        for (j=0; j<N; j+=4)
      55  	s += C[j];
      56        B[i+1] = B[i] + s;
      57      }
      58  
      59    /* check results:  */
      60    for (i = 0; i < 4; i++)
      61      {
      62        if (B[i] != E[i])
      63  	abort ();
      64      }
      65  
      66    return 0;
      67  }
      68  
      69  int main ()
      70  {
      71    check_vect ();
      72    return main1();
      73  }
      74  
      75  /* NOTE: We temporarily xfail the following check until versioning for
      76     aliasing is fixed to avoid versioning when the dependence distance
      77     is known.  */
      78  /* { dg-final { scan-tree-dump-times "not vectorized: possible dependence between data-refs" 1 "vect" { xfail *-*-* } } } */
      79  /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */
      80  /* { dg-final { scan-tree-dump "zero step in outer loop." "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */