[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / clzsi2_test.c
blobfc517cf144ae4763abbf03c4325ee4de5a7f03e9
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_clzsi2
3 //===-- clzsi2_test.c - Test __clzsi2 -------------------------------------===//
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 __clzsi2 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
18 // Returns: the number of leading 0-bits
20 // Precondition: a != 0
22 COMPILER_RT_ABI si_int __clzsi2(si_int a);
24 int test__clzsi2(si_int a, si_int expected)
26 si_int x = __clzsi2(a);
27 if (x != expected)
28 printf("error in __clzsi2(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__clzsi2(0x00000000, 32)) // undefined
38 // return 1;
39 if (test__clzsi2(0x00800000, 8))
40 return 1;
41 if (test__clzsi2(0x01000000, 7))
42 return 1;
43 if (test__clzsi2(0x02000000, 6))
44 return 1;
45 if (test__clzsi2(0x03000000, 6))
46 return 1;
47 if (test__clzsi2(0x04000000, 5))
48 return 1;
49 if (test__clzsi2(0x05000000, 5))
50 return 1;
51 if (test__clzsi2(0x06000000, 5))
52 return 1;
53 if (test__clzsi2(0x07000000, 5))
54 return 1;
55 if (test__clzsi2(0x08000000, 4))
56 return 1;
57 if (test__clzsi2(0x09000000, 4))
58 return 1;
59 if (test__clzsi2(0x0A000000, 4))
60 return 1;
61 if (test__clzsi2(0x0B000000, 4))
62 return 1;
63 if (test__clzsi2(0x0C000000, 4))
64 return 1;
65 if (test__clzsi2(0x0D000000, 4))
66 return 1;
67 if (test__clzsi2(0x0E000000, 4))
68 return 1;
69 if (test__clzsi2(0x0F000000, 4))
70 return 1;
71 if (test__clzsi2(0x10000000, 3))
72 return 1;
73 if (test__clzsi2(0x11000000, 3))
74 return 1;
75 if (test__clzsi2(0x12000000, 3))
76 return 1;
77 if (test__clzsi2(0x13000000, 3))
78 return 1;
79 if (test__clzsi2(0x14000000, 3))
80 return 1;
81 if (test__clzsi2(0x15000000, 3))
82 return 1;
83 if (test__clzsi2(0x16000000, 3))
84 return 1;
85 if (test__clzsi2(0x17000000, 3))
86 return 1;
87 if (test__clzsi2(0x18000000, 3))
88 return 1;
89 if (test__clzsi2(0x19000000, 3))
90 return 1;
91 if (test__clzsi2(0x1A000000, 3))
92 return 1;
93 if (test__clzsi2(0x1B000000, 3))
94 return 1;
95 if (test__clzsi2(0x1C000000, 3))
96 return 1;
97 if (test__clzsi2(0x1D000000, 3))
98 return 1;
99 if (test__clzsi2(0x1E000000, 3))
100 return 1;
101 if (test__clzsi2(0x1F000000, 3))
102 return 1;
103 if (test__clzsi2(0x20000000, 2))
104 return 1;
105 if (test__clzsi2(0x21000000, 2))
106 return 1;
107 if (test__clzsi2(0x22000000, 2))
108 return 1;
109 if (test__clzsi2(0x23000000, 2))
110 return 1;
111 if (test__clzsi2(0x24000000, 2))
112 return 1;
113 if (test__clzsi2(0x25000000, 2))
114 return 1;
115 if (test__clzsi2(0x26000000, 2))
116 return 1;
117 if (test__clzsi2(0x27000000, 2))
118 return 1;
119 if (test__clzsi2(0x28000000, 2))
120 return 1;
121 if (test__clzsi2(0x29000000, 2))
122 return 1;
123 if (test__clzsi2(0x2A000000, 2))
124 return 1;
125 if (test__clzsi2(0x2B000000, 2))
126 return 1;
127 if (test__clzsi2(0x2C000000, 2))
128 return 1;
129 if (test__clzsi2(0x2D000000, 2))
130 return 1;
131 if (test__clzsi2(0x2E000000, 2))
132 return 1;
133 if (test__clzsi2(0x2F000000, 2))
134 return 1;
135 if (test__clzsi2(0x30000000, 2))
136 return 1;
137 if (test__clzsi2(0x31000000, 2))
138 return 1;
139 if (test__clzsi2(0x32000000, 2))
140 return 1;
141 if (test__clzsi2(0x33000000, 2))
142 return 1;
143 if (test__clzsi2(0x34000000, 2))
144 return 1;
145 if (test__clzsi2(0x35000000, 2))
146 return 1;
147 if (test__clzsi2(0x36000000, 2))
148 return 1;
149 if (test__clzsi2(0x37000000, 2))
150 return 1;
151 if (test__clzsi2(0x38000000, 2))
152 return 1;
153 if (test__clzsi2(0x39000000, 2))
154 return 1;
155 if (test__clzsi2(0x3A000000, 2))
156 return 1;
157 if (test__clzsi2(0x3B000000, 2))
158 return 1;
159 if (test__clzsi2(0x3C000000, 2))
160 return 1;
161 if (test__clzsi2(0x3D000000, 2))
162 return 1;
163 if (test__clzsi2(0x3E000000, 2))
164 return 1;
165 if (test__clzsi2(0x3F000000, 2))
166 return 1;
167 if (test__clzsi2(0x40000000, 1))
168 return 1;
169 if (test__clzsi2(0x41000000, 1))
170 return 1;
171 if (test__clzsi2(0x42000000, 1))
172 return 1;
173 if (test__clzsi2(0x43000000, 1))
174 return 1;
175 if (test__clzsi2(0x44000000, 1))
176 return 1;
177 if (test__clzsi2(0x45000000, 1))
178 return 1;
179 if (test__clzsi2(0x46000000, 1))
180 return 1;
181 if (test__clzsi2(0x47000000, 1))
182 return 1;
183 if (test__clzsi2(0x48000000, 1))
184 return 1;
185 if (test__clzsi2(0x49000000, 1))
186 return 1;
187 if (test__clzsi2(0x4A000000, 1))
188 return 1;
189 if (test__clzsi2(0x4B000000, 1))
190 return 1;
191 if (test__clzsi2(0x4C000000, 1))
192 return 1;
193 if (test__clzsi2(0x4D000000, 1))
194 return 1;
195 if (test__clzsi2(0x4E000000, 1))
196 return 1;
197 if (test__clzsi2(0x4F000000, 1))
198 return 1;
199 if (test__clzsi2(0x50000000, 1))
200 return 1;
201 if (test__clzsi2(0x51000000, 1))
202 return 1;
203 if (test__clzsi2(0x52000000, 1))
204 return 1;
205 if (test__clzsi2(0x53000000, 1))
206 return 1;
207 if (test__clzsi2(0x54000000, 1))
208 return 1;
209 if (test__clzsi2(0x55000000, 1))
210 return 1;
211 if (test__clzsi2(0x56000000, 1))
212 return 1;
213 if (test__clzsi2(0x57000000, 1))
214 return 1;
215 if (test__clzsi2(0x58000000, 1))
216 return 1;
217 if (test__clzsi2(0x59000000, 1))
218 return 1;
219 if (test__clzsi2(0x5A000000, 1))
220 return 1;
221 if (test__clzsi2(0x5B000000, 1))
222 return 1;
223 if (test__clzsi2(0x5C000000, 1))
224 return 1;
225 if (test__clzsi2(0x5D000000, 1))
226 return 1;
227 if (test__clzsi2(0x5E000000, 1))
228 return 1;
229 if (test__clzsi2(0x5F000000, 1))
230 return 1;
231 if (test__clzsi2(0x60000000, 1))
232 return 1;
233 if (test__clzsi2(0x61000000, 1))
234 return 1;
235 if (test__clzsi2(0x62000000, 1))
236 return 1;
237 if (test__clzsi2(0x63000000, 1))
238 return 1;
239 if (test__clzsi2(0x64000000, 1))
240 return 1;
241 if (test__clzsi2(0x65000000, 1))
242 return 1;
243 if (test__clzsi2(0x66000000, 1))
244 return 1;
245 if (test__clzsi2(0x67000000, 1))
246 return 1;
247 if (test__clzsi2(0x68000000, 1))
248 return 1;
249 if (test__clzsi2(0x69000000, 1))
250 return 1;
251 if (test__clzsi2(0x6A000000, 1))
252 return 1;
253 if (test__clzsi2(0x6B000000, 1))
254 return 1;
255 if (test__clzsi2(0x6C000000, 1))
256 return 1;
257 if (test__clzsi2(0x6D000000, 1))
258 return 1;
259 if (test__clzsi2(0x6E000000, 1))
260 return 1;
261 if (test__clzsi2(0x6F000000, 1))
262 return 1;
263 if (test__clzsi2(0x70000000, 1))
264 return 1;
265 if (test__clzsi2(0x71000000, 1))
266 return 1;
267 if (test__clzsi2(0x72000000, 1))
268 return 1;
269 if (test__clzsi2(0x73000000, 1))
270 return 1;
271 if (test__clzsi2(0x74000000, 1))
272 return 1;
273 if (test__clzsi2(0x75000000, 1))
274 return 1;
275 if (test__clzsi2(0x76000000, 1))
276 return 1;
277 if (test__clzsi2(0x77000000, 1))
278 return 1;
279 if (test__clzsi2(0x78000000, 1))
280 return 1;
281 if (test__clzsi2(0x79000000, 1))
282 return 1;
283 if (test__clzsi2(0x7A000000, 1))
284 return 1;
285 if (test__clzsi2(0x7B000000, 1))
286 return 1;
287 if (test__clzsi2(0x7C000000, 1))
288 return 1;
289 if (test__clzsi2(0x7D000000, 1))
290 return 1;
291 if (test__clzsi2(0x7E000000, 1))
292 return 1;
293 if (test__clzsi2(0x7F000000, 1))
294 return 1;
295 if (test__clzsi2(0x80000000, 0))
296 return 1;
297 if (test__clzsi2(0x81000000, 0))
298 return 1;
299 if (test__clzsi2(0x82000000, 0))
300 return 1;
301 if (test__clzsi2(0x83000000, 0))
302 return 1;
303 if (test__clzsi2(0x84000000, 0))
304 return 1;
305 if (test__clzsi2(0x85000000, 0))
306 return 1;
307 if (test__clzsi2(0x86000000, 0))
308 return 1;
309 if (test__clzsi2(0x87000000, 0))
310 return 1;
311 if (test__clzsi2(0x88000000, 0))
312 return 1;
313 if (test__clzsi2(0x89000000, 0))
314 return 1;
315 if (test__clzsi2(0x8A000000, 0))
316 return 1;
317 if (test__clzsi2(0x8B000000, 0))
318 return 1;
319 if (test__clzsi2(0x8C000000, 0))
320 return 1;
321 if (test__clzsi2(0x8D000000, 0))
322 return 1;
323 if (test__clzsi2(0x8E000000, 0))
324 return 1;
325 if (test__clzsi2(0x8F000000, 0))
326 return 1;
327 if (test__clzsi2(0x90000000, 0))
328 return 1;
329 if (test__clzsi2(0x91000000, 0))
330 return 1;
331 if (test__clzsi2(0x92000000, 0))
332 return 1;
333 if (test__clzsi2(0x93000000, 0))
334 return 1;
335 if (test__clzsi2(0x94000000, 0))
336 return 1;
337 if (test__clzsi2(0x95000000, 0))
338 return 1;
339 if (test__clzsi2(0x96000000, 0))
340 return 1;
341 if (test__clzsi2(0x97000000, 0))
342 return 1;
343 if (test__clzsi2(0x98000000, 0))
344 return 1;
345 if (test__clzsi2(0x99000000, 0))
346 return 1;
347 if (test__clzsi2(0x9A000000, 0))
348 return 1;
349 if (test__clzsi2(0x9B000000, 0))
350 return 1;
351 if (test__clzsi2(0x9C000000, 0))
352 return 1;
353 if (test__clzsi2(0x9D000000, 0))
354 return 1;
355 if (test__clzsi2(0x9E000000, 0))
356 return 1;
357 if (test__clzsi2(0x9F000000, 0))
358 return 1;
359 if (test__clzsi2(0xA0000000, 0))
360 return 1;
361 if (test__clzsi2(0xA1000000, 0))
362 return 1;
363 if (test__clzsi2(0xA2000000, 0))
364 return 1;
365 if (test__clzsi2(0xA3000000, 0))
366 return 1;
367 if (test__clzsi2(0xA4000000, 0))
368 return 1;
369 if (test__clzsi2(0xA5000000, 0))
370 return 1;
371 if (test__clzsi2(0xA6000000, 0))
372 return 1;
373 if (test__clzsi2(0xA7000000, 0))
374 return 1;
375 if (test__clzsi2(0xA8000000, 0))
376 return 1;
377 if (test__clzsi2(0xA9000000, 0))
378 return 1;
379 if (test__clzsi2(0xAA000000, 0))
380 return 1;
381 if (test__clzsi2(0xAB000000, 0))
382 return 1;
383 if (test__clzsi2(0xAC000000, 0))
384 return 1;
385 if (test__clzsi2(0xAD000000, 0))
386 return 1;
387 if (test__clzsi2(0xAE000000, 0))
388 return 1;
389 if (test__clzsi2(0xAF000000, 0))
390 return 1;
391 if (test__clzsi2(0xB0000000, 0))
392 return 1;
393 if (test__clzsi2(0xB1000000, 0))
394 return 1;
395 if (test__clzsi2(0xB2000000, 0))
396 return 1;
397 if (test__clzsi2(0xB3000000, 0))
398 return 1;
399 if (test__clzsi2(0xB4000000, 0))
400 return 1;
401 if (test__clzsi2(0xB5000000, 0))
402 return 1;
403 if (test__clzsi2(0xB6000000, 0))
404 return 1;
405 if (test__clzsi2(0xB7000000, 0))
406 return 1;
407 if (test__clzsi2(0xB8000000, 0))
408 return 1;
409 if (test__clzsi2(0xB9000000, 0))
410 return 1;
411 if (test__clzsi2(0xBA000000, 0))
412 return 1;
413 if (test__clzsi2(0xBB000000, 0))
414 return 1;
415 if (test__clzsi2(0xBC000000, 0))
416 return 1;
417 if (test__clzsi2(0xBD000000, 0))
418 return 1;
419 if (test__clzsi2(0xBE000000, 0))
420 return 1;
421 if (test__clzsi2(0xBF000000, 0))
422 return 1;
423 if (test__clzsi2(0xC0000000, 0))
424 return 1;
425 if (test__clzsi2(0xC1000000, 0))
426 return 1;
427 if (test__clzsi2(0xC2000000, 0))
428 return 1;
429 if (test__clzsi2(0xC3000000, 0))
430 return 1;
431 if (test__clzsi2(0xC4000000, 0))
432 return 1;
433 if (test__clzsi2(0xC5000000, 0))
434 return 1;
435 if (test__clzsi2(0xC6000000, 0))
436 return 1;
437 if (test__clzsi2(0xC7000000, 0))
438 return 1;
439 if (test__clzsi2(0xC8000000, 0))
440 return 1;
441 if (test__clzsi2(0xC9000000, 0))
442 return 1;
443 if (test__clzsi2(0xCA000000, 0))
444 return 1;
445 if (test__clzsi2(0xCB000000, 0))
446 return 1;
447 if (test__clzsi2(0xCC000000, 0))
448 return 1;
449 if (test__clzsi2(0xCD000000, 0))
450 return 1;
451 if (test__clzsi2(0xCE000000, 0))
452 return 1;
453 if (test__clzsi2(0xCF000000, 0))
454 return 1;
455 if (test__clzsi2(0xD0000000, 0))
456 return 1;
457 if (test__clzsi2(0xD1000000, 0))
458 return 1;
459 if (test__clzsi2(0xD2000000, 0))
460 return 1;
461 if (test__clzsi2(0xD3000000, 0))
462 return 1;
463 if (test__clzsi2(0xD4000000, 0))
464 return 1;
465 if (test__clzsi2(0xD5000000, 0))
466 return 1;
467 if (test__clzsi2(0xD6000000, 0))
468 return 1;
469 if (test__clzsi2(0xD7000000, 0))
470 return 1;
471 if (test__clzsi2(0xD8000000, 0))
472 return 1;
473 if (test__clzsi2(0xD9000000, 0))
474 return 1;
475 if (test__clzsi2(0xDA000000, 0))
476 return 1;
477 if (test__clzsi2(0xDB000000, 0))
478 return 1;
479 if (test__clzsi2(0xDC000000, 0))
480 return 1;
481 if (test__clzsi2(0xDD000000, 0))
482 return 1;
483 if (test__clzsi2(0xDE000000, 0))
484 return 1;
485 if (test__clzsi2(0xDF000000, 0))
486 return 1;
487 if (test__clzsi2(0xE0000000, 0))
488 return 1;
489 if (test__clzsi2(0xE1000000, 0))
490 return 1;
491 if (test__clzsi2(0xE2000000, 0))
492 return 1;
493 if (test__clzsi2(0xE3000000, 0))
494 return 1;
495 if (test__clzsi2(0xE4000000, 0))
496 return 1;
497 if (test__clzsi2(0xE5000000, 0))
498 return 1;
499 if (test__clzsi2(0xE6000000, 0))
500 return 1;
501 if (test__clzsi2(0xE7000000, 0))
502 return 1;
503 if (test__clzsi2(0xE8000000, 0))
504 return 1;
505 if (test__clzsi2(0xE9000000, 0))
506 return 1;
507 if (test__clzsi2(0xEA000000, 0))
508 return 1;
509 if (test__clzsi2(0xEB000000, 0))
510 return 1;
511 if (test__clzsi2(0xEC000000, 0))
512 return 1;
513 if (test__clzsi2(0xED000000, 0))
514 return 1;
515 if (test__clzsi2(0xEE000000, 0))
516 return 1;
517 if (test__clzsi2(0xEF000000, 0))
518 return 1;
519 if (test__clzsi2(0xF0000000, 0))
520 return 1;
521 if (test__clzsi2(0xF1000000, 0))
522 return 1;
523 if (test__clzsi2(0xF2000000, 0))
524 return 1;
525 if (test__clzsi2(0xF3000000, 0))
526 return 1;
527 if (test__clzsi2(0xF4000000, 0))
528 return 1;
529 if (test__clzsi2(0xF5000000, 0))
530 return 1;
531 if (test__clzsi2(0xF6000000, 0))
532 return 1;
533 if (test__clzsi2(0xF7000000, 0))
534 return 1;
535 if (test__clzsi2(0xF8000000, 0))
536 return 1;
537 if (test__clzsi2(0xF9000000, 0))
538 return 1;
539 if (test__clzsi2(0xFA000000, 0))
540 return 1;
541 if (test__clzsi2(0xFB000000, 0))
542 return 1;
543 if (test__clzsi2(0xFC000000, 0))
544 return 1;
545 if (test__clzsi2(0xFD000000, 0))
546 return 1;
547 if (test__clzsi2(0xFE000000, 0))
548 return 1;
549 if (test__clzsi2(0xFF000000, 0))
550 return 1;
552 if (test__clzsi2(0x00000001, 31))
553 return 1;
554 if (test__clzsi2(0x00000002, 30))
555 return 1;
556 if (test__clzsi2(0x00000004, 29))
557 return 1;
558 if (test__clzsi2(0x00000008, 28))
559 return 1;
560 if (test__clzsi2(0x00000010, 27))
561 return 1;
562 if (test__clzsi2(0x00000020, 26))
563 return 1;
564 if (test__clzsi2(0x00000040, 25))
565 return 1;
566 if (test__clzsi2(0x00000080, 24))
567 return 1;
568 if (test__clzsi2(0x00000100, 23))
569 return 1;
570 if (test__clzsi2(0x00000200, 22))
571 return 1;
572 if (test__clzsi2(0x00000400, 21))
573 return 1;
574 if (test__clzsi2(0x00000800, 20))
575 return 1;
576 if (test__clzsi2(0x00001000, 19))
577 return 1;
578 if (test__clzsi2(0x00002000, 18))
579 return 1;
580 if (test__clzsi2(0x00004000, 17))
581 return 1;
582 if (test__clzsi2(0x00008000, 16))
583 return 1;
584 if (test__clzsi2(0x00010000, 15))
585 return 1;
586 if (test__clzsi2(0x00020000, 14))
587 return 1;
588 if (test__clzsi2(0x00040000, 13))
589 return 1;
590 if (test__clzsi2(0x00080000, 12))
591 return 1;
592 if (test__clzsi2(0x00100000, 11))
593 return 1;
594 if (test__clzsi2(0x00200000, 10))
595 return 1;
596 if (test__clzsi2(0x00400000, 9))
597 return 1;
599 return 0;