2018-01-16 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-outer-simd-2.c
blob3ae1020936f960a5e46d6c74bee80d3b52df6db5
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
7 float *px, *py;
8 float *tx, *ty;
9 float *x1, *z1, *t1, *t2;
11 static void inline bar (const float cx, float cy,
12 float *vx, float *vy)
14 int j;
15 for (j = 0; j < N; ++j)
17 const float dx = cx - px[j];
18 const float dy = cy - py[j];
19 *vx -= dx * tx[j];
20 *vy -= dy * ty[j];
24 __attribute__((noinline, noclone)) void foo1 (int n)
26 int i;
27 #pragma omp simd
28 for (i=0; i<n; i++)
29 bar (px[i], py[i], x1+i, z1+i);
32 __attribute__((noinline, noclone)) void foo2 (int n)
34 volatile int i;
35 for (i=0; i<n; i++)
36 bar (px[i], py[i], x1+i, z1+i);
40 int main ()
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];
55 for (i=0; i<N; i++)
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;
63 foo1 (n); /* vector variant. */
64 for (i=0; i<N;i++)
66 t1[i] = x1[i]; x1[i] = 1.0f;
67 t2[i] = z1[i]; z1[i] = 1.0f;
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;
75 /* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" } } */