1 /* { dg-additional-options "-ffast-math" } */
14 #define TEST_BIT_BUILTINS(T, S, S2) \
17 = {0##S, 1##S, 2##S, 3##S, \
18 111##S, 333##S, 444##S, 0x80000000##S, \
19 0x0000ffff##S, 0xf0000000##S, 0xff000000##S, 0xffffffff##S}; \
24 int parity[N2] = {}; \
25 int popcount[N2] = {}; \
27 _Pragma ("omp target map(to:clz[:N2], ctz[:N2], ffs[:N2], parity[:N2], popcount[:N2])") \
29 for (unsigned i = 0; i < N2; i++) \
31 clrsb[i] = __builtin_clrsb##S2 (arguments[i]); \
32 clz[i] = __builtin_clz##S2 (arguments[i]); \
33 ctz[i] = __builtin_ctz##S2 (arguments[i]); \
34 ffs[i] = __builtin_ffs##S2 (arguments[i]); \
35 parity[i] = __builtin_parity##S2 (arguments[i]); \
36 popcount[i] = __builtin_popcount##S2 (arguments[i]); \
40 for (unsigned i = 0; i < N2; i++) \
42 assert (clrsb[i] == __builtin_clrsb##S2 (arguments[i])); \
43 if (arguments[0] != 0) \
45 assert (clz[i] == __builtin_clz##S2 (arguments[i])); \
46 assert (ctz[i] == __builtin_ctz##S2 (arguments[i])); \
48 assert (ffs[i] == __builtin_ffs##S2 (arguments[i])); \
49 assert (parity[i] == __builtin_parity##S2 (arguments[i])); \
50 assert (popcount[i] == __builtin_popcount##S2 (arguments[i])); \
54 #define ASSERT(v1, v2) assert (fabs (v1 - v2) < DELTA)
62 /* 1) test direct mapping to HSA insns. */
64 #pragma omp target map(to: f[ : N], d[ : N])
77 ASSERT (f
[0], sinf (c1
));
78 ASSERT (f
[1], cosf (c1
));
79 ASSERT (f
[2], exp2f (c1
));
80 ASSERT (f
[3], log2f (c1
));
81 ASSERT (f
[4], truncf (c1
));
82 ASSERT (f
[5], sqrtf (c1
));
84 ASSERT (d
[0], trunc (c2
));
85 ASSERT (d
[1], sqrt (c2
));
87 /* 2) test bit builtins for unsigned int. */
88 TEST_BIT_BUILTINS (int, , );
90 /* 3) test bit builtins for unsigned long int. */
91 TEST_BIT_BUILTINS (long, l
, l
);
93 /* 4) test bit builtins for unsigned long long int. */
94 TEST_BIT_BUILTINS (long long, ll
, ll
);