* tree-loop-distribution.c (struct partition): New field recording
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-outer-simd-1.c
blob217b32cd2bde12247f94f36787ccdf67bb014ba2
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 ()
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 ()
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 check_vect ();
45 px = &X[0];
46 py = &X[N * 1];
47 tx = &X[N * 2];
48 ty = &X[N * 3];
49 x1 = &X[N * 4];
50 z1 = &X[N * 5];
51 t1 = &X[N * 6];
52 t2 = &X[N * 7];
54 for (i=0; i<N; i++)
56 px[i] = (float) (i+2);
57 tx[i] = (float) (i+1);
58 py[i] = (float) (i+4);
59 ty[i] = (float) (i+3);
60 x1[i] = z1[i] = 1.0f;
62 foo1 (); /* vector variant. */
63 for (i=0; i<N;i++)
65 t1[i] = x1[i]; x1[i] = 1.0f;
66 t2[i] = z1[i]; z1[i] = 1.0f;
68 foo2 (); /* scalar variant. */
69 for (i=0; i<N; i++)
70 if (x1[i] != t1[i] || z1[i] != t2[i])
71 abort ();
72 return 0;
74 /* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" } } */