1  /* { dg-require-effective-target vect_simd_clones } */
       2  /* { dg-additional-options "-fopenmp-simd -ffast-math" } */
       3  #include <stdlib.h>
       4  #include "tree-vect.h"
       5  #define N 64
       6  
       7  float *px, *py;
       8  float *tx, *ty;
       9  float *x1, *z1, *t1, *t2;
      10  
      11  static void inline bar (const float cx, float cy,
      12                           float *vx, float *vy)
      13  {
      14    int j;
      15      for (j = 0; j < N; ++j)
      16      {
      17          const float dx  = cx - px[j];
      18          const float dy  = cy - py[j];
      19          *vx               -= dx * tx[j];
      20          *vy               -= dy * ty[j];
      21      }
      22  }
      23  
      24  __attribute__((noinline, noclone)) void foo1 (int n)
      25  {
      26    int i;
      27  #pragma omp simd
      28    for (i=0; i<n; i++)
      29      bar (px[i], py[i], x1+i, z1+i);
      30  }
      31  
      32  __attribute__((noinline, noclone)) void foo2 (int n)
      33  {
      34    volatile int i;
      35    for (i=0; i<n; i++)
      36      bar (px[i], py[i], x1+i, z1+i);
      37  }
      38  
      39  
      40  int main ()
      41  {
      42    float *X = (float*)malloc (N * 8 * sizeof (float));
      43    int i;
      44    int n = N - 1;
      45    check_vect ();
      46    px = &X[0];
      47    py = &X[N * 1];
      48    tx = &X[N * 2];
      49    ty = &X[N * 3];
      50    x1 = &X[N * 4];
      51    z1 = &X[N * 5];
      52    t1 = &X[N * 6];
      53    t2 = &X[N * 7];
      54  
      55    for (i=0; i<N; i++)
      56      {
      57        px[i] = (float) (i+2);
      58        tx[i] = (float) (i+1);
      59        py[i] = (float) (i+4);
      60        ty[i] = (float) (i+3);
      61        x1[i] = z1[i] = 1.0f;
      62      }
      63    foo1 (n);  /* vector variant.  */
      64    for (i=0; i<N;i++)
      65      {
      66        t1[i] = x1[i]; x1[i] = 1.0f;
      67        t2[i] = z1[i]; z1[i] = 1.0f;
      68      }
      69    foo2 (n);  /* scalar variant.  */
      70    for (i=0; i<N; i++)
      71      if (x1[i] != t1[i] || z1[i] != t2[i])
      72        abort ();
      73    return 0;
      74  }
      75  /* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" } } */