Debian Codegraph @

gcc/testsuite/c-c++-common/pr111309-1.c

raw
1 /* PR c/111309 */
2 /* { dg-do run } */
3 /* { dg-options "-O2" } */
4
5 __attribute__((noipa)) int
6 clzc (unsigned char x)
7 {
8 return __builtin_clzg (x);
9 }
10
11 __attribute__((noipa)) int
12 clzc2 (unsigned char x, int y)
13 {
14 return __builtin_clzg (x, y);
15 }
16
17 __attribute__((noipa)) int
18 clzs (unsigned short x)
19 {
20 return __builtin_clzg (x);
21 }
22
23 __attribute__((noipa)) int
24 clzs2 (unsigned short x)
25 {
26 return __builtin_clzg (x, -2);
27 }
28
29 __attribute__((noipa)) int
30 clzi (unsigned int x)
31 {
32 return __builtin_clzg (x);
33 }
34
35 __attribute__((noipa)) int
36 clzi2 (unsigned int x, int y)
37 {
38 return __builtin_clzg (x, y);
39 }
40
41 __attribute__((noipa)) int
42 clzl (unsigned long x)
43 {
44 return __builtin_clzg (x);
45 }
46
47 __attribute__((noipa)) int
48 clzl2 (unsigned long x)
49 {
50 return __builtin_clzg (x, -1);
51 }
52
53 __attribute__((noipa)) int
54 clzL (unsigned long long x)
55 {
56 return __builtin_clzg (x);
57 }
58
59 __attribute__((noipa)) int
60 clzL2 (unsigned long long x, int y)
61 {
62 return __builtin_clzg (x, y);
63 }
64
65 #ifdef __SIZEOF_INT128__
66 __attribute__((noipa)) int
67 clzI (unsigned __int128 x)
68 {
69 return __builtin_clzg (x);
70 }
71
72 __attribute__((noipa)) int
73 clzI2 (unsigned __int128 x, int y)
74 {
75 return __builtin_clzg (x, y);
76 }
77 #endif
78
79 __attribute__((noipa)) int
80 ctzc (unsigned char x)
81 {
82 return __builtin_ctzg (x);
83 }
84
85 __attribute__((noipa)) int
86 ctzc2 (unsigned char x, int y)
87 {
88 return __builtin_ctzg (x, y);
89 }
90
91 __attribute__((noipa)) int
92 ctzs (unsigned short x)
93 {
94 return __builtin_ctzg (x);
95 }
96
97 __attribute__((noipa)) int
98 ctzs2 (unsigned short x, int y)
99 {
100 return __builtin_ctzg (x, y);
101 }
102
103 __attribute__((noipa)) int
104 ctzi (unsigned int x)
105 {
106 return __builtin_ctzg (x);
107 }
108
109 __attribute__((noipa)) int
110 ctzi2 (unsigned int x, int y)
111 {
112 return __builtin_ctzg (x, y);
113 }
114
115 __attribute__((noipa)) int
116 ctzl (unsigned long x)
117 {
118 return __builtin_ctzg (x);
119 }
120
121 __attribute__((noipa)) int
122 ctzl2 (unsigned long x, int y)
123 {
124 return __builtin_ctzg (x, y);
125 }
126
127 __attribute__((noipa)) int
128 ctzL (unsigned long long x)
129 {
130 return __builtin_ctzg (x);
131 }
132
133 __attribute__((noipa)) int
134 ctzL2 (unsigned long long x, int y)
135 {
136 return __builtin_ctzg (x, y);
137 }
138
139 #ifdef __SIZEOF_INT128__
140 __attribute__((noipa)) int
141 ctzI (unsigned __int128 x)
142 {
143 return __builtin_ctzg (x);
144 }
145
146 __attribute__((noipa)) int
147 ctzI2 (unsigned __int128 x)
148 {
149 return __builtin_ctzg (x, __SIZEOF_INT128__ * __CHAR_BIT__);
150 }
151 #endif
152
153 __attribute__((noipa)) int
154 clrsbc (signed char x)
155 {
156 return __builtin_clrsbg (x);
157 }
158
159 __attribute__((noipa)) int
160 clrsbs (signed short x)
161 {
162 return __builtin_clrsbg (x);
163 }
164
165 __attribute__((noipa)) int
166 clrsbi (signed int x)
167 {
168 return __builtin_clrsbg (x);
169 }
170
171 __attribute__((noipa)) int
172 clrsbl (signed long x)
173 {
174 return __builtin_clrsbg (x);
175 }
176
177 __attribute__((noipa)) int
178 clrsbL (signed long long x)
179 {
180 return __builtin_clrsbg (x);
181 }
182
183 #ifdef __SIZEOF_INT128__
184 __attribute__((noipa)) int
185 clrsbI (signed __int128 x)
186 {
187 return __builtin_clrsbg (x);
188 }
189 #endif
190
191 __attribute__((noipa)) int
192 ffsc (signed char x)
193 {
194 return __builtin_ffsg (x);
195 }
196
197 __attribute__((noipa)) int
198 ffss (signed short x)
199 {
200 return __builtin_ffsg (x);
201 }
202
203 __attribute__((noipa)) int
204 ffsi (signed int x)
205 {
206 return __builtin_ffsg (x);
207 }
208
209 __attribute__((noipa)) int
210 ffsl (signed long x)
211 {
212 return __builtin_ffsg (x);
213 }
214
215 __attribute__((noipa)) int
216 ffsL (signed long long x)
217 {
218 return __builtin_ffsg (x);
219 }
220
221 #ifdef __SIZEOF_INT128__
222 __attribute__((noipa)) int
223 ffsI (signed __int128 x)
224 {
225 return __builtin_ffsg (x);
226 }
227 #endif
228
229 __attribute__((noipa)) int
230 parityc (unsigned char x)
231 {
232 return __builtin_parityg (x);
233 }
234
235 __attribute__((noipa)) int
236 paritys (unsigned short x)
237 {
238 return __builtin_parityg (x);
239 }
240
241 __attribute__((noipa)) int
242 parityi (unsigned int x)
243 {
244 return __builtin_parityg (x);
245 }
246
247 __attribute__((noipa)) int
248 parityl (unsigned long x)
249 {
250 return __builtin_parityg (x);
251 }
252
253 __attribute__((noipa)) int
254 parityL (unsigned long long x)
255 {
256 return __builtin_parityg (x);
257 }
258
259 #ifdef __SIZEOF_INT128__
260 __attribute__((noipa)) int
261 parityI (unsigned __int128 x)
262 {
263 return __builtin_parityg (x);
264 }
265 #endif
266
267 __attribute__((noipa)) int
268 popcountc (unsigned char x)
269 {
270 return __builtin_popcountg (x);
271 }
272
273 __attribute__((noipa)) int
274 popcounts (unsigned short x)
275 {
276 return __builtin_popcountg (x);
277 }
278
279 __attribute__((noipa)) int
280 popcounti (unsigned int x)
281 {
282 return __builtin_popcountg (x);
283 }
284
285 __attribute__((noipa)) int
286 popcountl (unsigned long x)
287 {
288 return __builtin_popcountg (x);
289 }
290
291 __attribute__((noipa)) int
292 popcountL (unsigned long long x)
293 {
294 return __builtin_popcountg (x);
295 }
296
297 #ifdef __SIZEOF_INT128__
298 __attribute__((noipa)) int
299 popcountI (unsigned __int128 x)
300 {
301 return __builtin_popcountg (x);
302 }
303 #endif
304
305 int
306 main ()
307 {
308 if (__builtin_clzg ((unsigned char) 1) != __CHAR_BIT__ - 1
309 || __builtin_clzg ((unsigned short) 2, -2) != __SIZEOF_SHORT__ * __CHAR_BIT__ - 2
310 || __builtin_clzg (0U, 42) != 42
311 || __builtin_clzg (0U, -1) != -1
312 || __builtin_clzg (1U) != __SIZEOF_INT__ * __CHAR_BIT__ - 1
313 || __builtin_clzg (2UL, -1) != __SIZEOF_LONG__ * __CHAR_BIT__ - 2
314 || __builtin_clzg (5ULL) != __SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 3
315 #ifdef __SIZEOF_INT128__
316 || __builtin_clzg ((unsigned __int128) 9) != __SIZEOF_INT128__ * __CHAR_BIT__ - 4
317 #endif
318 || __builtin_clzg (~0U, -5) != 0
319 || __builtin_clzg (~0ULL >> 2) != 2
320 || __builtin_ctzg ((unsigned char) 1) != 0
321 || __builtin_ctzg ((unsigned short) 28) != 2
322 || __builtin_ctzg (0U, 32) != 32
323 || __builtin_ctzg (0U, -42) != -42
324 || __builtin_ctzg (1U) != 0
325 || __builtin_ctzg (16UL, -1) != 4
326 || __builtin_ctzg (5ULL << 52, 0) != 52
327 #ifdef __SIZEOF_INT128__
328 || __builtin_ctzg (((unsigned __int128) 9) << 72) != 72
329 #endif
330 || __builtin_clrsbg ((signed char) 0) != __CHAR_BIT__ - 1
331 || __builtin_clrsbg ((signed short) -1) != __SIZEOF_SHORT__ * __CHAR_BIT__ - 1
332 || __builtin_clrsbg (0) != __SIZEOF_INT__ * __CHAR_BIT__ - 1
333 || __builtin_clrsbg (-1L) != __SIZEOF_LONG__ * __CHAR_BIT__ - 1
334 || __builtin_clrsbg (0LL) != __SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 1
335 #ifdef __SIZEOF_INT128__
336 || __builtin_clrsbg ((__int128) -1) != __SIZEOF_INT128__ * __CHAR_BIT__ - 1
337 #endif
338 || __builtin_clrsbg (0x1afb) != __SIZEOF_INT__ * __CHAR_BIT__ - 14
339 || __builtin_clrsbg (-2) != __SIZEOF_INT__ * __CHAR_BIT__ - 2
340 || __builtin_clrsbg (1L) != __SIZEOF_LONG__ * __CHAR_BIT__ - 2
341 || __builtin_clrsbg (-4LL) != __SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 3
342 || __builtin_ffsg ((signed char) 0) != 0
343 || __builtin_ffsg ((signed short) 0) != 0
344 || __builtin_ffsg (0) != 0
345 || __builtin_ffsg (0L) != 0
346 || __builtin_ffsg (0LL) != 0
347 #ifdef __SIZEOF_INT128__
348 || __builtin_ffsg ((__int128) 0) != 0
349 #endif
350 || __builtin_ffsg ((signed char) 4) != 3
351 || __builtin_ffsg ((signed short) 8) != 4
352 || __builtin_ffsg (1) != 1
353 || __builtin_ffsg (2L) != 2
354 || __builtin_ffsg (28LL) != 3
355 || __builtin_parityg ((unsigned char) 1) != 1
356 || __builtin_parityg ((unsigned short) 2) != 1
357 || __builtin_parityg (0U) != 0
358 || __builtin_parityg (3U) != 0
359 || __builtin_parityg (0UL) != 0
360 || __builtin_parityg (7UL) != 1
361 || __builtin_parityg (0ULL) != 0
362 #ifdef __SIZEOF_INT128__
363 || __builtin_parityg ((unsigned __int128) 0) != 0
364 #endif
365 || __builtin_parityg ((unsigned char) ~0U) != 0
366 || __builtin_parityg ((unsigned short) ~0U) != 0
367 || __builtin_parityg (~0U) != 0
368 || __builtin_parityg (~0UL) != 0
369 || __builtin_parityg (~0ULL) != 0
370 #ifdef __SIZEOF_INT128__
371 || __builtin_parityg (~(unsigned __int128) 0) != 0
372 #endif
373 || __builtin_popcountg (0U) != 0
374 || __builtin_popcountg (0UL) != 0
375 || __builtin_popcountg (0ULL) != 0
376 #ifdef __SIZEOF_INT128__
377 || __builtin_popcountg ((unsigned __int128) 0) != 0
378 #endif
379 || __builtin_popcountg ((unsigned char) ~0U) != __CHAR_BIT__
380 || __builtin_popcountg ((unsigned short) ~0U) != __SIZEOF_SHORT__ * __CHAR_BIT__
381 || __builtin_popcountg (~0U) != __SIZEOF_INT__ * __CHAR_BIT__
382 || __builtin_popcountg (~0UL) != __SIZEOF_LONG__ * __CHAR_BIT__
383 || __builtin_popcountg (~0ULL) != __SIZEOF_LONG_LONG__ * __CHAR_BIT__
384 #ifdef __SIZEOF_INT128__
385 || __builtin_popcountg (~(unsigned __int128) 0) != __SIZEOF_INT128__ * __CHAR_BIT__
386 #endif
387 || 0)
388 __builtin_abort ();
389 if (clzc (1) != __CHAR_BIT__ - 1
390 || clzs2 (2) != __SIZEOF_SHORT__ * __CHAR_BIT__ - 2
391 || clzi2 (0U, 42) != 42
392 || clzi2 (0U, -1) != -1
393 || clzi (1U) != __SIZEOF_INT__ * __CHAR_BIT__ - 1
394 || clzl2 (2UL) != __SIZEOF_LONG__ * __CHAR_BIT__ - 2
395 || clzL (5ULL) != __SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 3
396 #ifdef __SIZEOF_INT128__
397 || clzI ((unsigned __int128) 9) != __SIZEOF_INT128__ * __CHAR_BIT__ - 4
398 #endif
399 || clzi2 (~0U, -5) != 0
400 || clzL (~0ULL >> 2) != 2
401 || ctzc (1) != 0
402 || ctzs (28) != 2
403 || ctzi2 (0U, 32) != 32
404 || ctzi2 (0U, -42) != -42
405 || ctzi (1U) != 0
406 || ctzl2 (16UL, -1) != 4
407 || ctzL2 (5ULL << 52, 0) != 52
408 #ifdef __SIZEOF_INT128__
409 || ctzI (((unsigned __int128) 9) << 72) != 72
410 #endif
411 || clrsbc (0) != __CHAR_BIT__ - 1
412 || clrsbs (-1) != __SIZEOF_SHORT__ * __CHAR_BIT__ - 1
413 || clrsbi (0) != __SIZEOF_INT__ * __CHAR_BIT__ - 1
414 || clrsbl (-1L) != __SIZEOF_LONG__ * __CHAR_BIT__ - 1
415 || clrsbL (0LL) != __SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 1
416 #ifdef __SIZEOF_INT128__
417 || clrsbI (-1) != __SIZEOF_INT128__ * __CHAR_BIT__ - 1
418 #endif
419 || clrsbi (0x1afb) != __SIZEOF_INT__ * __CHAR_BIT__ - 14
420 || clrsbi (-2) != __SIZEOF_INT__ * __CHAR_BIT__ - 2
421 || clrsbl (1L) != __SIZEOF_LONG__ * __CHAR_BIT__ - 2
422 || clrsbL (-4LL) != __SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 3
423 || ffsc (0) != 0
424 || ffss (0) != 0
425 || ffsi (0) != 0
426 || ffsl (0L) != 0
427 || ffsL (0LL) != 0
428 #ifdef __SIZEOF_INT128__
429 || ffsI (0) != 0
430 #endif
431 || ffsc (4) != 3
432 || ffss (8) != 4
433 || ffsi (1) != 1
434 || ffsl (2L) != 2
435 || ffsL (28LL) != 3
436 || parityc (1) != 1
437 || paritys (2) != 1
438 || parityi (0U) != 0
439 || parityi (3U) != 0
440 || parityl (0UL) != 0
441 || parityl (7UL) != 1
442 || parityL (0ULL) != 0
443 #ifdef __SIZEOF_INT128__
444 || parityI (0) != 0
445 #endif
446 || parityc ((unsigned char) ~0U) != 0
447 || paritys ((unsigned short) ~0U) != 0
448 || parityi (~0U) != 0
449 || parityl (~0UL) != 0
450 || parityL (~0ULL) != 0
451 #ifdef __SIZEOF_INT128__
452 || parityI (~(unsigned __int128) 0) != 0
453 #endif
454 || popcounti (0U) != 0
455 || popcountl (0UL) != 0
456 || popcountL (0ULL) != 0
457 #ifdef __SIZEOF_INT128__
458 || popcountI (0) != 0
459 #endif
460 || popcountc ((unsigned char) ~0U) != __CHAR_BIT__
461 || popcounts ((unsigned short) ~0U) != __SIZEOF_SHORT__ * __CHAR_BIT__
462 || popcounti (~0U) != __SIZEOF_INT__ * __CHAR_BIT__
463 || popcountl (~0UL) != __SIZEOF_LONG__ * __CHAR_BIT__
464 || popcountL (~0ULL) != __SIZEOF_LONG_LONG__ * __CHAR_BIT__
465 #ifdef __SIZEOF_INT128__
466 || popcountI (~(unsigned __int128) 0) != __SIZEOF_INT128__ * __CHAR_BIT__
467 #endif
468 || 0)
469 __builtin_abort ();
470 }