libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / slp-21.c
blob0528a144e579e23cf94c1445f95ec0cc4b743753
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 128
8 int
9 main1 ()
11 unsigned short i;
12 unsigned short out[N*8], out2[N*8], b0, b1, b2, b3, b4, a0, a1, a2, a3, b5;
13 unsigned short in[N*8];
15 #pragma GCC novector
16 for (i = 0; i < N*8; i++)
18 in[i] = i;
21 /* Different operations in both cases - vectorization with interleaving. */
22 for (i = 0; i < N; i++)
24 a0 = in[i*4];
25 a1 = in[i*4 + 1];
26 a2 = in[i*4 + 2];
27 a3 = in[i*4 + 3];
29 b0 = a0 * 8;
30 b1 = a1 + 7;
31 b2 = a2 + 6;
32 b3 = a3 * 5;
34 b4 = a2 + 4;
35 b5 = a3 + 3;
37 out[i*4] = b0;
38 out[i*4 + 1] = b1;
39 out[i*4 + 2] = b2;
40 out[i*4 + 3] = b3;
42 out2[i*4] = b0;
43 out2[i*4 + 1] = b1;
44 out2[i*4 + 2] = b4;
45 out2[i*4 + 3] = b5;
48 /* check results: */
49 #pragma GCC novector
50 for (i = 0; i < N; i++)
52 a0 = in[i*4];
53 a1 = in[i*4 + 1];
54 a2 = in[i*4 + 2];
55 a3 = in[i*4 + 3];
57 b0 = a0 * 8;
58 b1 = a1 + 7;
59 b2 = a2 + 6;
60 b3 = a3 * 5;
62 b4 = a2 + 4;
63 b5 = a3 + 3;
65 if (out[i*4] != b0
66 || out[i*4 + 1] != b1
67 || out[i*4 + 2] != b2
68 || out[i*4 + 3] != b3)
69 abort ();
71 if (out2[i*4] != b0
72 || out2[i*4 + 1] != b1
73 || out2[i*4 + 2] != b4
74 || out2[i*4 + 3] != b5)
75 abort ();
78 /* Different operations in the first case - vectorization with interleaving. */
79 for (i = 0; i < N; i++)
81 a0 = in[i*4];
82 a1 = in[i*4 + 1];
83 a2 = in[i*4 + 2];
84 a3 = in[i*4 + 3];
86 b0 = a0 + 8;
87 b1 = a1 + 7;
88 b2 = a2 + 6;
89 b3 = a3 * 5;
91 b4 = a2 + 4;
92 b5 = a3 + 3;
94 out[i*4] = b0;
95 out[i*4 + 1] = b1;
96 out[i*4 + 2] = b2;
97 out[i*4 + 3] = b3;
99 out2[i*4] = b0;
100 out2[i*4 + 1] = b1;
101 out2[i*4 + 2] = b4;
102 out2[i*4 + 3] = b5;
105 /* check results: */
106 #pragma GCC novector
107 for (i = 0; i < N; i++)
109 a0 = in[i*4];
110 a1 = in[i*4 + 1];
111 a2 = in[i*4 + 2];
112 a3 = in[i*4 + 3];
114 b0 = a0 + 8;
115 b1 = a1 + 7;
116 b2 = a2 + 6;
117 b3 = a3 * 5;
119 b4 = a2 + 4;
120 b5 = a3 + 3;
122 if (out[i*4] != b0
123 || out[i*4 + 1] != b1
124 || out[i*4 + 2] != b2
125 || out[i*4 + 3] != b3)
126 abort ();
128 if (out2[i*4] != b0
129 || out2[i*4 + 1] != b1
130 || out2[i*4 + 2] != b4
131 || out2[i*4 + 3] != b5)
132 abort ();
136 /* Different operations in the second case - vectorization with interleaving. */
137 for (i = 0; i < N; i++)
139 a0 = in[i*4];
140 a1 = in[i*4 + 1];
141 a2 = in[i*4 + 2];
142 a3 = in[i*4 + 3];
144 b0 = a0 + 8;
145 b1 = a1 + 7;
146 b2 = a2 + 6;
147 b3 = a3 + 5;
149 b4 = a2 * 4;
150 b5 = a3 + 3;
152 out[i*4] = b0;
153 out[i*4 + 1] = b1;
154 out[i*4 + 2] = b2;
155 out[i*4 + 3] = b3;
157 out2[i*4] = b0;
158 out2[i*4 + 1] = b1;
159 out2[i*4 + 2] = b4;
160 out2[i*4 + 3] = b5;
163 /* check results: */
164 #pragma GCC novector
165 for (i = 0; i < N; i++)
167 a0 = in[i*4];
168 a1 = in[i*4 + 1];
169 a2 = in[i*4 + 2];
170 a3 = in[i*4 + 3];
172 b0 = a0 + 8;
173 b1 = a1 + 7;
174 b2 = a2 + 6;
175 b3 = a3 + 5;
177 b4 = a2 * 4;
178 b5 = a3 + 3;
180 if (out[i*4] != b0
181 || out[i*4 + 1] != b1
182 || out[i*4 + 2] != b2
183 || out[i*4 + 3] != b3)
184 abort ();
186 if (out2[i*4] != b0
187 || out2[i*4 + 1] != b1
188 || out2[i*4 + 2] != b4
189 || out2[i*4 + 3] != b5)
190 abort ();
194 return 0;
197 int main (void)
199 check_vect ();
201 main1 ();
203 return 0;
206 /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { vect_strided4 || vect_extract_even_odd } } } } */
207 /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! { vect_strided4 || vect_extract_even_odd } } } } } */