[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / ctzsi2_test.c
blob26c0adf8df839ac271c33a4158f4bf273bd92926
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_ctzsi2
3 //===-- ctzsi2_test.c - Test __ctzsi2 -------------------------------------===//
4 //
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //
9 //===----------------------------------------------------------------------===//
11 // This file tests __ctzsi2 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
18 // Returns: the number of trailing 0-bits
20 // Precondition: a != 0
22 COMPILER_RT_ABI si_int __ctzsi2(si_int a);
24 int test__ctzsi2(si_int a, si_int expected)
26 si_int x = __ctzsi2(a);
27 if (x != expected)
28 printf("error in __ctzsi2(0x%X) = %d, expected %d\n", a, x, expected);
29 return x != expected;
32 char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
33 char assumption_2[sizeof(si_int)*CHAR_BIT == 32] = {0};
35 int main()
37 // if (test__ctzsi2(0x00000000, 32)) // undefined
38 // return 1;
39 if (test__ctzsi2(0x00000001, 0))
40 return 1;
41 if (test__ctzsi2(0x00000002, 1))
42 return 1;
43 if (test__ctzsi2(0x00000003, 0))
44 return 1;
45 if (test__ctzsi2(0x00000004, 2))
46 return 1;
47 if (test__ctzsi2(0x00000005, 0))
48 return 1;
49 if (test__ctzsi2(0x00000006, 1))
50 return 1;
51 if (test__ctzsi2(0x00000007, 0))
52 return 1;
53 if (test__ctzsi2(0x00000008, 3))
54 return 1;
55 if (test__ctzsi2(0x00000009, 0))
56 return 1;
57 if (test__ctzsi2(0x0000000A, 1))
58 return 1;
59 if (test__ctzsi2(0x0000000B, 0))
60 return 1;
61 if (test__ctzsi2(0x0000000C, 2))
62 return 1;
63 if (test__ctzsi2(0x0000000D, 0))
64 return 1;
65 if (test__ctzsi2(0x0000000E, 1))
66 return 1;
67 if (test__ctzsi2(0x0000000F, 0))
68 return 1;
69 if (test__ctzsi2(0x00000010, 4))
70 return 1;
71 if (test__ctzsi2(0x00000012, 1))
72 return 1;
73 if (test__ctzsi2(0x00000013, 0))
74 return 1;
75 if (test__ctzsi2(0x00000014, 2))
76 return 1;
77 if (test__ctzsi2(0x00000015, 0))
78 return 1;
79 if (test__ctzsi2(0x00000016, 1))
80 return 1;
81 if (test__ctzsi2(0x00000017, 0))
82 return 1;
83 if (test__ctzsi2(0x00000018, 3))
84 return 1;
85 if (test__ctzsi2(0x00000019, 0))
86 return 1;
87 if (test__ctzsi2(0x0000001A, 1))
88 return 1;
89 if (test__ctzsi2(0x0000001B, 0))
90 return 1;
91 if (test__ctzsi2(0x0000001C, 2))
92 return 1;
93 if (test__ctzsi2(0x0000001D, 0))
94 return 1;
95 if (test__ctzsi2(0x0000001E, 1))
96 return 1;
97 if (test__ctzsi2(0x0000001F, 0))
98 return 1;
99 if (test__ctzsi2(0x00000020, 5))
100 return 1;
101 if (test__ctzsi2(0x00000022, 1))
102 return 1;
103 if (test__ctzsi2(0x00000023, 0))
104 return 1;
105 if (test__ctzsi2(0x00000024, 2))
106 return 1;
107 if (test__ctzsi2(0x00000025, 0))
108 return 1;
109 if (test__ctzsi2(0x00000026, 1))
110 return 1;
111 if (test__ctzsi2(0x00000027, 0))
112 return 1;
113 if (test__ctzsi2(0x00000028, 3))
114 return 1;
115 if (test__ctzsi2(0x00000029, 0))
116 return 1;
117 if (test__ctzsi2(0x0000002A, 1))
118 return 1;
119 if (test__ctzsi2(0x0000002B, 0))
120 return 1;
121 if (test__ctzsi2(0x0000002C, 2))
122 return 1;
123 if (test__ctzsi2(0x0000002D, 0))
124 return 1;
125 if (test__ctzsi2(0x0000002E, 1))
126 return 1;
127 if (test__ctzsi2(0x0000002F, 0))
128 return 1;
129 if (test__ctzsi2(0x00000030, 4))
130 return 1;
131 if (test__ctzsi2(0x00000032, 1))
132 return 1;
133 if (test__ctzsi2(0x00000033, 0))
134 return 1;
135 if (test__ctzsi2(0x00000034, 2))
136 return 1;
137 if (test__ctzsi2(0x00000035, 0))
138 return 1;
139 if (test__ctzsi2(0x00000036, 1))
140 return 1;
141 if (test__ctzsi2(0x00000037, 0))
142 return 1;
143 if (test__ctzsi2(0x00000038, 3))
144 return 1;
145 if (test__ctzsi2(0x00000039, 0))
146 return 1;
147 if (test__ctzsi2(0x0000003A, 1))
148 return 1;
149 if (test__ctzsi2(0x0000003B, 0))
150 return 1;
151 if (test__ctzsi2(0x0000003C, 2))
152 return 1;
153 if (test__ctzsi2(0x0000003D, 0))
154 return 1;
155 if (test__ctzsi2(0x0000003E, 1))
156 return 1;
157 if (test__ctzsi2(0x0000003F, 0))
158 return 1;
159 if (test__ctzsi2(0x00000040, 6))
160 return 1;
161 if (test__ctzsi2(0x00000042, 1))
162 return 1;
163 if (test__ctzsi2(0x00000043, 0))
164 return 1;
165 if (test__ctzsi2(0x00000044, 2))
166 return 1;
167 if (test__ctzsi2(0x00000045, 0))
168 return 1;
169 if (test__ctzsi2(0x00000046, 1))
170 return 1;
171 if (test__ctzsi2(0x00000047, 0))
172 return 1;
173 if (test__ctzsi2(0x00000048, 3))
174 return 1;
175 if (test__ctzsi2(0x00000049, 0))
176 return 1;
177 if (test__ctzsi2(0x0000004A, 1))
178 return 1;
179 if (test__ctzsi2(0x0000004B, 0))
180 return 1;
181 if (test__ctzsi2(0x0000004C, 2))
182 return 1;
183 if (test__ctzsi2(0x0000004D, 0))
184 return 1;
185 if (test__ctzsi2(0x0000004E, 1))
186 return 1;
187 if (test__ctzsi2(0x0000004F, 0))
188 return 1;
189 if (test__ctzsi2(0x00000050, 4))
190 return 1;
191 if (test__ctzsi2(0x00000052, 1))
192 return 1;
193 if (test__ctzsi2(0x00000053, 0))
194 return 1;
195 if (test__ctzsi2(0x00000054, 2))
196 return 1;
197 if (test__ctzsi2(0x00000055, 0))
198 return 1;
199 if (test__ctzsi2(0x00000056, 1))
200 return 1;
201 if (test__ctzsi2(0x00000057, 0))
202 return 1;
203 if (test__ctzsi2(0x00000058, 3))
204 return 1;
205 if (test__ctzsi2(0x00000059, 0))
206 return 1;
207 if (test__ctzsi2(0x0000005A, 1))
208 return 1;
209 if (test__ctzsi2(0x0000005B, 0))
210 return 1;
211 if (test__ctzsi2(0x0000005C, 2))
212 return 1;
213 if (test__ctzsi2(0x0000005D, 0))
214 return 1;
215 if (test__ctzsi2(0x0000005E, 1))
216 return 1;
217 if (test__ctzsi2(0x0000005F, 0))
218 return 1;
219 if (test__ctzsi2(0x00000060, 5))
220 return 1;
221 if (test__ctzsi2(0x00000062, 1))
222 return 1;
223 if (test__ctzsi2(0x00000063, 0))
224 return 1;
225 if (test__ctzsi2(0x00000064, 2))
226 return 1;
227 if (test__ctzsi2(0x00000065, 0))
228 return 1;
229 if (test__ctzsi2(0x00000066, 1))
230 return 1;
231 if (test__ctzsi2(0x00000067, 0))
232 return 1;
233 if (test__ctzsi2(0x00000068, 3))
234 return 1;
235 if (test__ctzsi2(0x00000069, 0))
236 return 1;
237 if (test__ctzsi2(0x0000006A, 1))
238 return 1;
239 if (test__ctzsi2(0x0000006B, 0))
240 return 1;
241 if (test__ctzsi2(0x0000006C, 2))
242 return 1;
243 if (test__ctzsi2(0x0000006D, 0))
244 return 1;
245 if (test__ctzsi2(0x0000006E, 1))
246 return 1;
247 if (test__ctzsi2(0x0000006F, 0))
248 return 1;
249 if (test__ctzsi2(0x00000070, 4))
250 return 1;
251 if (test__ctzsi2(0x00000072, 1))
252 return 1;
253 if (test__ctzsi2(0x00000073, 0))
254 return 1;
255 if (test__ctzsi2(0x00000074, 2))
256 return 1;
257 if (test__ctzsi2(0x00000075, 0))
258 return 1;
259 if (test__ctzsi2(0x00000076, 1))
260 return 1;
261 if (test__ctzsi2(0x00000077, 0))
262 return 1;
263 if (test__ctzsi2(0x00000078, 3))
264 return 1;
265 if (test__ctzsi2(0x00000079, 0))
266 return 1;
267 if (test__ctzsi2(0x0000007A, 1))
268 return 1;
269 if (test__ctzsi2(0x0000007B, 0))
270 return 1;
271 if (test__ctzsi2(0x0000007C, 2))
272 return 1;
273 if (test__ctzsi2(0x0000007D, 0))
274 return 1;
275 if (test__ctzsi2(0x0000007E, 1))
276 return 1;
277 if (test__ctzsi2(0x0000007F, 0))
278 return 1;
279 if (test__ctzsi2(0x00000080, 7))
280 return 1;
281 if (test__ctzsi2(0x00000082, 1))
282 return 1;
283 if (test__ctzsi2(0x00000083, 0))
284 return 1;
285 if (test__ctzsi2(0x00000084, 2))
286 return 1;
287 if (test__ctzsi2(0x00000085, 0))
288 return 1;
289 if (test__ctzsi2(0x00000086, 1))
290 return 1;
291 if (test__ctzsi2(0x00000087, 0))
292 return 1;
293 if (test__ctzsi2(0x00000088, 3))
294 return 1;
295 if (test__ctzsi2(0x00000089, 0))
296 return 1;
297 if (test__ctzsi2(0x0000008A, 1))
298 return 1;
299 if (test__ctzsi2(0x0000008B, 0))
300 return 1;
301 if (test__ctzsi2(0x0000008C, 2))
302 return 1;
303 if (test__ctzsi2(0x0000008D, 0))
304 return 1;
305 if (test__ctzsi2(0x0000008E, 1))
306 return 1;
307 if (test__ctzsi2(0x0000008F, 0))
308 return 1;
309 if (test__ctzsi2(0x00000090, 4))
310 return 1;
311 if (test__ctzsi2(0x00000092, 1))
312 return 1;
313 if (test__ctzsi2(0x00000093, 0))
314 return 1;
315 if (test__ctzsi2(0x00000094, 2))
316 return 1;
317 if (test__ctzsi2(0x00000095, 0))
318 return 1;
319 if (test__ctzsi2(0x00000096, 1))
320 return 1;
321 if (test__ctzsi2(0x00000097, 0))
322 return 1;
323 if (test__ctzsi2(0x00000098, 3))
324 return 1;
325 if (test__ctzsi2(0x00000099, 0))
326 return 1;
327 if (test__ctzsi2(0x0000009A, 1))
328 return 1;
329 if (test__ctzsi2(0x0000009B, 0))
330 return 1;
331 if (test__ctzsi2(0x0000009C, 2))
332 return 1;
333 if (test__ctzsi2(0x0000009D, 0))
334 return 1;
335 if (test__ctzsi2(0x0000009E, 1))
336 return 1;
337 if (test__ctzsi2(0x0000009F, 0))
338 return 1;
339 if (test__ctzsi2(0x000000A0, 5))
340 return 1;
341 if (test__ctzsi2(0x000000A2, 1))
342 return 1;
343 if (test__ctzsi2(0x000000A3, 0))
344 return 1;
345 if (test__ctzsi2(0x000000A4, 2))
346 return 1;
347 if (test__ctzsi2(0x000000A5, 0))
348 return 1;
349 if (test__ctzsi2(0x000000A6, 1))
350 return 1;
351 if (test__ctzsi2(0x000000A7, 0))
352 return 1;
353 if (test__ctzsi2(0x000000A8, 3))
354 return 1;
355 if (test__ctzsi2(0x000000A9, 0))
356 return 1;
357 if (test__ctzsi2(0x000000AA, 1))
358 return 1;
359 if (test__ctzsi2(0x000000AB, 0))
360 return 1;
361 if (test__ctzsi2(0x000000AC, 2))
362 return 1;
363 if (test__ctzsi2(0x000000AD, 0))
364 return 1;
365 if (test__ctzsi2(0x000000AE, 1))
366 return 1;
367 if (test__ctzsi2(0x000000AF, 0))
368 return 1;
369 if (test__ctzsi2(0x000000B0, 4))
370 return 1;
371 if (test__ctzsi2(0x000000B2, 1))
372 return 1;
373 if (test__ctzsi2(0x000000B3, 0))
374 return 1;
375 if (test__ctzsi2(0x000000B4, 2))
376 return 1;
377 if (test__ctzsi2(0x000000B5, 0))
378 return 1;
379 if (test__ctzsi2(0x000000B6, 1))
380 return 1;
381 if (test__ctzsi2(0x000000B7, 0))
382 return 1;
383 if (test__ctzsi2(0x000000B8, 3))
384 return 1;
385 if (test__ctzsi2(0x000000B9, 0))
386 return 1;
387 if (test__ctzsi2(0x000000BA, 1))
388 return 1;
389 if (test__ctzsi2(0x000000BB, 0))
390 return 1;
391 if (test__ctzsi2(0x000000BC, 2))
392 return 1;
393 if (test__ctzsi2(0x000000BD, 0))
394 return 1;
395 if (test__ctzsi2(0x000000BE, 1))
396 return 1;
397 if (test__ctzsi2(0x000000BF, 0))
398 return 1;
399 if (test__ctzsi2(0x000000C0, 6))
400 return 1;
401 if (test__ctzsi2(0x000000C2, 1))
402 return 1;
403 if (test__ctzsi2(0x000000C3, 0))
404 return 1;
405 if (test__ctzsi2(0x000000C4, 2))
406 return 1;
407 if (test__ctzsi2(0x000000C5, 0))
408 return 1;
409 if (test__ctzsi2(0x000000C6, 1))
410 return 1;
411 if (test__ctzsi2(0x000000C7, 0))
412 return 1;
413 if (test__ctzsi2(0x000000C8, 3))
414 return 1;
415 if (test__ctzsi2(0x000000C9, 0))
416 return 1;
417 if (test__ctzsi2(0x000000CA, 1))
418 return 1;
419 if (test__ctzsi2(0x000000CB, 0))
420 return 1;
421 if (test__ctzsi2(0x000000CC, 2))
422 return 1;
423 if (test__ctzsi2(0x000000CD, 0))
424 return 1;
425 if (test__ctzsi2(0x000000CE, 1))
426 return 1;
427 if (test__ctzsi2(0x000000CF, 0))
428 return 1;
429 if (test__ctzsi2(0x000000D0, 4))
430 return 1;
431 if (test__ctzsi2(0x000000D2, 1))
432 return 1;
433 if (test__ctzsi2(0x000000D3, 0))
434 return 1;
435 if (test__ctzsi2(0x000000D4, 2))
436 return 1;
437 if (test__ctzsi2(0x000000D5, 0))
438 return 1;
439 if (test__ctzsi2(0x000000D6, 1))
440 return 1;
441 if (test__ctzsi2(0x000000D7, 0))
442 return 1;
443 if (test__ctzsi2(0x000000D8, 3))
444 return 1;
445 if (test__ctzsi2(0x000000D9, 0))
446 return 1;
447 if (test__ctzsi2(0x000000DA, 1))
448 return 1;
449 if (test__ctzsi2(0x000000DB, 0))
450 return 1;
451 if (test__ctzsi2(0x000000DC, 2))
452 return 1;
453 if (test__ctzsi2(0x000000DD, 0))
454 return 1;
455 if (test__ctzsi2(0x000000DE, 1))
456 return 1;
457 if (test__ctzsi2(0x000000DF, 0))
458 return 1;
459 if (test__ctzsi2(0x000000E0, 5))
460 return 1;
461 if (test__ctzsi2(0x000000E2, 1))
462 return 1;
463 if (test__ctzsi2(0x000000E3, 0))
464 return 1;
465 if (test__ctzsi2(0x000000E4, 2))
466 return 1;
467 if (test__ctzsi2(0x000000E5, 0))
468 return 1;
469 if (test__ctzsi2(0x000000E6, 1))
470 return 1;
471 if (test__ctzsi2(0x000000E7, 0))
472 return 1;
473 if (test__ctzsi2(0x000000E8, 3))
474 return 1;
475 if (test__ctzsi2(0x000000E9, 0))
476 return 1;
477 if (test__ctzsi2(0x000000EA, 1))
478 return 1;
479 if (test__ctzsi2(0x000000EB, 0))
480 return 1;
481 if (test__ctzsi2(0x000000EC, 2))
482 return 1;
483 if (test__ctzsi2(0x000000ED, 0))
484 return 1;
485 if (test__ctzsi2(0x000000EE, 1))
486 return 1;
487 if (test__ctzsi2(0x000000EF, 0))
488 return 1;
489 if (test__ctzsi2(0x000000F0, 4))
490 return 1;
491 if (test__ctzsi2(0x000000F2, 1))
492 return 1;
493 if (test__ctzsi2(0x000000F3, 0))
494 return 1;
495 if (test__ctzsi2(0x000000F4, 2))
496 return 1;
497 if (test__ctzsi2(0x000000F5, 0))
498 return 1;
499 if (test__ctzsi2(0x000000F6, 1))
500 return 1;
501 if (test__ctzsi2(0x000000F7, 0))
502 return 1;
503 if (test__ctzsi2(0x000000F8, 3))
504 return 1;
505 if (test__ctzsi2(0x000000F9, 0))
506 return 1;
507 if (test__ctzsi2(0x000000FA, 1))
508 return 1;
509 if (test__ctzsi2(0x000000FB, 0))
510 return 1;
511 if (test__ctzsi2(0x000000FC, 2))
512 return 1;
513 if (test__ctzsi2(0x000000FD, 0))
514 return 1;
515 if (test__ctzsi2(0x000000FE, 1))
516 return 1;
517 if (test__ctzsi2(0x000000FF, 0))
518 return 1;
520 if (test__ctzsi2(0x00000100, 8))
521 return 1;
522 if (test__ctzsi2(0x00000200, 9))
523 return 1;
524 if (test__ctzsi2(0x00000400, 10))
525 return 1;
526 if (test__ctzsi2(0x00000800, 11))
527 return 1;
528 if (test__ctzsi2(0x00001000, 12))
529 return 1;
530 if (test__ctzsi2(0x00002000, 13))
531 return 1;
532 if (test__ctzsi2(0x00004000, 14))
533 return 1;
534 if (test__ctzsi2(0x00008000, 15))
535 return 1;
536 if (test__ctzsi2(0x00010000, 16))
537 return 1;
538 if (test__ctzsi2(0x00020000, 17))
539 return 1;
540 if (test__ctzsi2(0x00040000, 18))
541 return 1;
542 if (test__ctzsi2(0x00080000, 19))
543 return 1;
544 if (test__ctzsi2(0x00100000, 20))
545 return 1;
546 if (test__ctzsi2(0x00200000, 21))
547 return 1;
548 if (test__ctzsi2(0x00400000, 22))
549 return 1;
550 if (test__ctzsi2(0x00800000, 23))
551 return 1;
552 if (test__ctzsi2(0x01000000, 24))
553 return 1;
554 if (test__ctzsi2(0x02000000, 25))
555 return 1;
556 if (test__ctzsi2(0x04000000, 26))
557 return 1;
558 if (test__ctzsi2(0x08000000, 27))
559 return 1;
560 if (test__ctzsi2(0x10000000, 28))
561 return 1;
562 if (test__ctzsi2(0x20000000, 29))
563 return 1;
564 if (test__ctzsi2(0x40000000, 30))
565 return 1;
566 if (test__ctzsi2(0x80000000, 31))
567 return 1;
569 return 0;