Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.dg / vect / vect-1.c
blob33d84de480546b1c30257f5c1e3631611975536a
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 int i,j;
23 int diff = 0;
24 char cb[N];
25 char cc[N];
26 char image[N][N];
27 char block[N][N];
29 /* Not vectorizable yet (cross-iteration cycle). */
30 diff = 0;
31 for (i = 0; i < N; i++) {
32 diff += (cb[i] - cc[i]);
34 ibar (&diff);
37 /* Not vectorizable yet (outer-loop: not attempted.
38 inner-loop: cross iteration cycle; multi-dimensional arrays). */
39 diff = 0;
40 for (i = 0; i < N; i++) {
41 for (i = 0; i < N; i++) {
42 diff += (image[i][j] - block[i][j]);
45 ibar (&diff);
48 /* Vectorizable. */
49 for (i = 0; i < N; i++){
50 a[i] = b[i];
52 fbar (a);
55 /* Vectorizable. */
56 for (i = 0; i < N; i++){
57 a[i] = b[i] + c[i] + d[i];
59 fbar (a);
62 /* Interleaved access. Not vectorizable yet (access pattern) on platforms
63 that don't support interleaving. */
64 for (i = 0; i < N/2; i++){
65 a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i];
66 d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i];
68 fbar (a);
71 /* Vectorizable. */
72 for (i = 0; i < N; i++){
73 a[i] = b[i] + c[i];
74 d[i] = b[i] + c[i];
75 ia[i] = ib[i] + ic[i];
77 ibar (ia);
78 fbar (a);
79 fbar (d);
81 /* Not vetorizable yet (too conservative dependence test). */
82 for (i = 0; i < N; i++){
83 a[i] = b[i] + c[i];
84 a[i+1] = b[i] + c[i];
86 fbar (a);
89 /* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_strided } } } */
90 /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_strided} } } */
91 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
92 /* { dg-final { cleanup-tree-dump "vect" } } */