* testsuite/libgomp.fortran/vla7.f90: Add -w to options.
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-1.c
blob938a7b3d1814ba98f414cbda82bab6795ef35b99
1 /* { dg-do compile } */
2 /* { dg-require-effective-target vect_int } */
3 /* { dg-require-effective-target vect_float } */
5 #define N 16
7 void fbar (float *);
8 void ibar (int *);
9 void sbar (short *);
11 /* multiple loops */
13 foo (int n)
15 float a[N+1];
16 float b[N];
17 float c[N];
18 float d[N];
19 int ia[N];
20 int ib[N];
21 int ic[N];
22 short sa[N];
23 short sb[N];
24 short sc[N];
25 int i,j;
26 int diff = 0;
27 char cb[N];
28 char cc[N];
29 char image[N][N];
30 char block[N][N];
32 /* Not vectorizable yet (cross-iteration cycle). */
33 diff = 0;
34 for (i = 0; i < N; i++) {
35 diff += (cb[i] - cc[i]);
37 ibar (&diff);
40 /* Not vectorizable yet (outer-loop: not attempted.
41 inner-loop: cross iteration cycle; multi-dimensional arrays). */
42 diff = 0;
43 for (i = 0; i < N; i++) {
44 for (i = 0; i < N; i++) {
45 diff += (image[i][j] - block[i][j]);
48 ibar (&diff);
51 /* Vectorizable. */
52 for (i = 0; i < N; i++){
53 a[i] = b[i];
55 fbar (a);
58 /* Vectorizable. */
59 for (i = 0; i < N; i++){
60 a[i] = b[i] + c[i] + d[i];
62 fbar (a);
65 /* Not vectorizable yet (access pattern). */
66 for (i = 0; i < N/2; i++){
67 a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i];
68 d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i];
70 fbar (a);
73 /* Vectorizable. */
74 for (i = 0; i < N; i++){
75 a[i] = b[i] + c[i];
76 d[i] = b[i] + c[i];
77 ia[i] = ib[i] + ic[i];
79 ibar (ia);
80 fbar (a);
81 fbar (d);
84 /* Not vectorizable yet (two types with different nunits in vector). */
85 for (i = 0; i < N; i++){
86 ia[i] = ib[i] + ic[i];
87 sa[i] = sb[i] + sc[i];
89 ibar (ia);
90 sbar (sa);
93 /* Not vetorizable yet (too conservative dependence test). */
94 for (i = 0; i < N; i++){
95 a[i] = b[i] + c[i];
96 a[i+1] = b[i] + c[i];
98 fbar (a);
101 /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
102 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
103 /* { dg-final { cleanup-tree-dump "vect" } } */