[AMDGPU] Remove s_wakeup_barrier instruction (#122277)
[llvm-project.git] / compiler-rt / test / builtins / Unit / paritysi2_test.c
blob2bed010d9d4ade1e5f43d9f0881d76d5eceaa7ee
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_paritysi2
4 #include "int_lib.h"
5 #include <stdio.h>
6 #include <stdlib.h>
8 // Returns: 1 if number of bits is odd else returns 0
10 COMPILER_RT_ABI int __paritysi2(si_int a);
12 int naive_parity(si_int a)
14 int r = 0;
15 for (; a; a = a & (a - 1))
16 r = ~r;
17 return r & 1;
20 int test__paritysi2(si_int a)
22 si_int x = __paritysi2(a);
23 si_int expected = naive_parity(a);
24 if (x != expected)
25 printf("error in __paritysi2(0x%X) = %d, expected %d\n",
26 a, x, expected);
27 return x != expected;
30 char assumption_2[sizeof(si_int)*CHAR_BIT == 32] = {0};
32 int main()
34 int i;
35 for (i = 0; i < 10000; ++i)
36 if (test__paritysi2(rand()))
37 return 1;
39 return 0;