Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / cswtch-3.c
blobb983c8fbe9280a52829d86d6d7363c306a31c556
1 /* PR tree-optimization/79472 */
2 /* { dg-options "-O2 -fdump-tree-switchconv" } */
3 /* { dg-do run } */
5 int *expected;
7 void
8 foo (int x, int y)
10 if (x != expected[0] || y != expected[1])
11 __builtin_abort ();
12 expected += 2;
15 __attribute__((noinline, noclone)) void
16 f1 (int v, int w)
18 int i, j;
19 if (w)
21 i = 129;
22 j = i - 1;
23 goto lab;
25 switch (v)
27 case 170:
28 j = 7;
29 i = 27;
30 break;
31 case 171:
32 i = 8;
33 j = 122;
34 break;
35 case 172:
36 i = 21;
37 j = -19;
38 break;
39 case 173:
40 i = 18;
41 j = 17;
42 break;
43 case 174:
44 i = 139;
45 j = -5;
46 break;
47 case 175:
48 i = 14;
49 j = -26;
50 break;
51 case 176:
52 j = 5;
53 i = -14;
54 break;
55 case 177:
56 j = 8;
57 i = 12;
58 break;
59 default:
60 __builtin_abort ();
63 lab:
64 foo (i, j);
67 __attribute__((noinline, noclone)) void
68 f2 (int v)
70 int i, j;
71 switch (v)
73 case 170:
74 j = 7;
75 i = 27;
76 break;
77 case 171:
78 i = 8;
79 j = 122;
80 break;
81 case 172:
82 i = 21;
83 j = -19;
84 break;
85 case 173:
86 i = 18;
87 j = 17;
88 break;
89 case 174:
90 i = 139;
91 j = -5;
92 break;
93 case 175:
94 i = 14;
95 j = -26;
96 break;
97 case 176:
98 j = 5;
99 i = -14;
100 break;
101 case 177:
102 j = 8;
103 i = 12;
104 break;
105 default:
106 foo (5, 12);
107 foo (17, 19);
108 i = 8;
109 j = 19;
110 break;
113 foo (i, j);
116 __attribute__((noinline, noclone)) void
117 f3 (int v)
119 int i;
120 switch (v)
122 default:
123 i = v;
124 goto lab;
125 case 170:
126 i = 27;
127 break;
128 case 171:
129 i = 8;
130 break;
131 case 172:
132 i = 21;
133 break;
134 case 173:
135 i = 18;
136 break;
137 case 174:
138 i = 139;
139 break;
140 case 175:
141 i = 14;
142 break;
143 case 176:
144 i = -14;
145 break;
146 case 177:
147 i = 12;
148 break;
151 lab:
152 foo (i, -5);
155 __attribute__((noinline, noclone)) void
156 f4 (int v, int w)
158 int i, j, k = 5;
159 if (w)
161 foo (0, 0);
162 k = 26;
163 goto do_default;
165 switch (v)
167 case 170:
168 j = 7;
169 i = 27;
170 break;
171 case 171:
172 i = 8;
173 j = 122;
174 break;
175 case 172:
176 i = 21;
177 j = -19;
178 break;
179 case 173:
180 i = 18;
181 j = 17;
182 break;
183 case 174:
184 i = 139;
185 j = -5;
186 break;
187 case 175:
188 i = 14;
189 j = -26;
190 break;
191 case 176:
192 j = 5;
193 i = -14;
194 break;
195 case 177:
196 j = 8;
197 i = 12;
198 break;
199 default:
200 do_default:
201 foo (5, 12);
202 foo (17, 19);
203 i = 8;
204 j = 19;
205 break;
208 foo (i, j + k);
211 void
212 f5 (int v, int w)
214 int i;
215 if (w)
217 foo (23, 0);
218 i = 129;
220 else
221 switch (v)
223 case 170:
224 i = 27;
225 break;
226 case 171:
227 i = 8;
228 break;
229 case 172:
230 i = 21;
231 break;
232 case 173:
233 i = 18;
234 break;
235 case 174:
236 i = 139;
237 break;
238 case 175:
239 i = 14;
240 break;
241 case 176:
242 i = -14;
243 break;
244 case 177:
245 i = 12;
246 break;
247 default:
248 i = 80;
249 break;
252 lab:
253 foo (i, 0);
257 main ()
259 int *e;
260 #define T(call, cnt, ...) \
261 expected = e = (int []) __VA_ARGS__; \
262 call; \
263 if (expected != e + cnt) \
264 __builtin_abort ()
265 T (f1 (171, 1), 2, { 129, 128 });
266 T (f1 (140, 1), 2, { 129, 128 });
267 T (f1 (170, 0), 2, { 27, 7 });
268 T (f1 (171, 0), 2, { 8, 122 });
269 T (f1 (172, 0), 2, { 21, -19 });
270 T (f1 (173, 0), 2, { 18, 17 });
271 T (f1 (174, 0), 2, { 139, -5 });
272 T (f1 (175, 0), 2, { 14, -26 });
273 T (f1 (176, 0), 2, { -14, 5 });
274 T (f1 (177, 0), 2, { 12, 8 });
275 T (f2 (-31), 6, { 5, 12, 17, 19, 8, 19 });
276 T (f2 (169), 6, { 5, 12, 17, 19, 8, 19 });
277 T (f2 (170), 2, { 27, 7 });
278 T (f2 (171), 2, { 8, 122 });
279 T (f2 (172), 2, { 21, -19 });
280 T (f2 (173), 2, { 18, 17 });
281 T (f2 (174), 2, { 139, -5 });
282 T (f2 (175), 2, { 14, -26 });
283 T (f2 (176), 2, { -14, 5 });
284 T (f2 (177), 2, { 12, 8 });
285 T (f2 (178), 6, { 5, 12, 17, 19, 8, 19 });
286 T (f2 (231), 6, { 5, 12, 17, 19, 8, 19 });
287 T (f3 (-31), 2, { -31, -5 });
288 T (f3 (169), 2, { 169, -5 });
289 T (f3 (170), 2, { 27, -5 });
290 T (f3 (171), 2, { 8, -5 });
291 T (f3 (172), 2, { 21, -5 });
292 T (f3 (173), 2, { 18, -5 });
293 T (f3 (174), 2, { 139, -5 });
294 T (f3 (175), 2, { 14, -5 });
295 T (f3 (176), 2, { -14, -5 });
296 T (f3 (177), 2, { 12, -5 });
297 T (f3 (178), 2, { 178, -5 });
298 T (f3 (231), 2, { 231, -5 });
299 T (f4 (171, 1), 8, { 0, 0, 5, 12, 17, 19, 8, 45 });
300 T (f4 (140, 1), 8, { 0, 0, 5, 12, 17, 19, 8, 45 });
301 T (f4 (-31, 0), 6, { 5, 12, 17, 19, 8, 24 });
302 T (f4 (169, 0), 6, { 5, 12, 17, 19, 8, 24 });
303 T (f4 (170, 0), 2, { 27, 12 });
304 T (f4 (171, 0), 2, { 8, 127 });
305 T (f4 (172, 0), 2, { 21, -14 });
306 T (f4 (173, 0), 2, { 18, 22 });
307 T (f4 (174, 0), 2, { 139, 0 });
308 T (f4 (175, 0), 2, { 14, -21 });
309 T (f4 (176, 0), 2, { -14, 10 });
310 T (f4 (177, 0), 2, { 12, 13 });
311 T (f4 (178, 0), 6, { 5, 12, 17, 19, 8, 24 });
312 T (f4 (231, 0), 6, { 5, 12, 17, 19, 8, 24 });
313 T (f5 (171, 1), 4, { 23, 0, 129, 0 });
314 T (f5 (140, 1), 4, { 23, 0, 129, 0 });
315 T (f5 (-31, 0), 2, { 80, 0 });
316 T (f5 (169, 0), 2, { 80, 0 });
317 T (f5 (170, 0), 2, { 27, 0 });
318 T (f5 (171, 0), 2, { 8, 0 });
319 T (f5 (172, 0), 2, { 21, 0 });
320 T (f5 (173, 0), 2, { 18, 0 });
321 T (f5 (174, 0), 2, { 139, 0 });
322 T (f5 (175, 0), 2, { 14, 0 });
323 T (f5 (176, 0), 2, { -14, 0 });
324 T (f5 (177, 0), 2, { 12, 0 });
325 T (f5 (178, 0), 2, { 80, 0 });
326 T (f5 (231, 0), 2, { 80, 0 });
329 /* { dg-final { scan-tree-dump-times "Switch converted" 5 "switchconv" } } */
330 /* { dg-final { scan-tree-dump-times "= CSWTCH" 8 "switchconv" } } */