libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-1-big-array.c
blob5ffbf1bf3aa00efdccebec70b147bcc85bd1a850
1 /* { dg-do compile } */
2 /* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */
3 /* { dg-require-effective-target vect_int } */
4 /* { dg-require-effective-target vect_float } */
6 #define N 128
8 void fbar (float *);
9 void ibar (int *);
10 void sbar (short *);
12 /* multiple loops */
14 void
15 foo (int n)
17 float a[N+1];
18 float b[N];
19 float c[N];
20 float d[N];
21 int ia[N];
22 int ib[N];
23 int ic[N];
24 int i,j;
25 int diff = 0;
26 char cb[N];
27 char cc[N];
28 char image[N][N];
29 char block[N][N];
31 /* Vectorizable. */
32 diff = 0;
33 for (i = 0; i < N; i++) {
34 diff += (cb[i] - cc[i]);
36 ibar (&diff);
39 /* Vectorizable. */
40 diff = 0;
41 for (i = 0; i < N; i++) {
42 for (j = 0; j < N; j++) {
43 diff += (image[i][j] - block[i][j]);
46 ibar (&diff);
49 /* Vectorizable. */
50 for (i = 0; i < N; i++){
51 a[i] = b[i];
53 fbar (a);
56 /* Vectorizable. */
57 for (i = 0; i < N; i++){
58 a[i] = b[i] + c[i] + d[i];
60 fbar (a);
63 /* Strided access. Vectorizable on platforms that support load of strided
64 accesses (extract of even/odd vector elements). */
65 for (i = 0; i < N/2; i++){
66 a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i];
67 d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i];
69 fbar (a);
72 /* Vectorizable. */
73 for (i = 0; i < N; i++){
74 a[i] = b[i] + c[i];
75 d[i] = b[i] + c[i];
76 ia[i] = ib[i] + ic[i];
78 ibar (ia);
79 fbar (a);
80 fbar (d);
82 /* Not vetorizable yet (too conservative dependence test). */
83 for (i = 0; i < N; i++){
84 a[i] = b[i] + c[i];
85 a[i+1] = b[i] + c[i];
87 fbar (a);
90 /* { dg-final { scan-tree-dump-times "vectorized 6 loops" 1 "vect" { target vect_strided2 } } } */
91 /* { dg-final { scan-tree-dump-times "vectorized 5 loops" 1 "vect" { xfail vect_strided2 } } } */
92 /* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */