1 /* { dg-require-effective-target vect_int } */
2 /* { dg-require-effective-target vect_float } */
10 float fadd_results[N];
11 float fmul_results[N];
15 /****************************************************/
16 __attribute__ ((noinline))
17 void icheck_results (int *a, int *results)
20 for (i = 0; i < N; i++)
22 if (a[i] != results[i])
27 __attribute__ ((noinline))
28 void fcheck_results (float *a, float *results)
31 for (i = 0; i < N; i++)
33 if (a[i] != results[i])
38 __attribute__ ((noinline)) void
41 fcheck_results (a, fmul_results);
44 __attribute__ ((noinline)) void
47 fcheck_results (a, fadd_results);
50 __attribute__ ((noinline)) void
53 icheck_results (a, iadd_results);
56 __attribute__ ((noinline)) void
59 fcheck_results (a, fresults1);
62 __attribute__ ((noinline)) void
65 fcheck_results (a, fresults2);
70 float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
71 float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
72 float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30};
73 int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
74 int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
76 char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
82 /* All of the loops below are currently vectorizable, except
83 initialization ones. */
85 __attribute__ ((noinline)) int
90 for (i = 0; i < N; i++)
98 fadd_results[i] = b[i] + c[i] + d[i];
99 iadd_results[i] = ib[i] + ic[i];
100 fmul_results[i] = b[i] * c[i];
107 /* Test 1: copy chars. */
108 for (i = 0; i < N; i++)
113 for (i = 0; i < N; i++)
120 /* Test 2: fp mult. */
121 for (i = 0; i < N; i++)
128 /* Test 3: mixed types (int, fp), same nunits in vector. */
129 for (i = 0; i < N; i++)
131 a[i] = b[i] + c[i] + d[i];
132 e[i] = b[i] + c[i] + d[i];
133 ia[i] = ib[i] + ic[i];
139 /* Initialization. */
140 for (i = 0; i < N; i++)
147 for (i = 0; i < N/2; i++)
149 fresults1[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i];
150 fresults2[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i];
154 /* Test 4: access with offset. */
155 for (i = 0; i < N/2; i++)
157 a[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i];
158 e[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i];
164 /* Test 5: access with offset. */
165 for (i = 1; i <=N-4; i++)
170 for (i = 1; i <=N-4; i++)
172 if (a[i+3] != b[i-1])
177 /* Test 6 - loop induction with stride != 1. */
187 for (i = 0; i <N; i++)
194 /* Test 7 - reverse access. */
195 for (i = N; i > 0; i--)
200 for (i = 0; i <N; i++)
207 /* Tests 8,9,10 - constants. */
208 for (i = 0; i < N; i++)
213 for (i = 0; i < N; i++)
219 for (i = 0; i < N; i++)
224 for (i = 0; i < N; i++)
230 for (i = 0; i < N; i++)
235 for (i = 0; i < N; i++)
237 if (ia[i] != ib[i] + 5)
251 /* { dg-final { scan-tree-dump-times "vectorized 10 loops" 1 "vect" } } */
252 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { target { { vect_aligned_arrays } && {! vect_sizes_32B_16B} } } } } */
253 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { {! vect_aligned_arrays } && {vect_sizes_32B_16B} } } } } */
254 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */
255 /* { dg-final { cleanup-tree-dump "vect" } } */