* tree-ssa-loop-ivopts.c (relate_compare_use_with_all_cands): Handle
[official-gcc.git] / libgomp / testsuite / libgomp.hsa.c / builtins-1.c
blobe603c21afcd28503ee83a34754a6a49c107b5724
1 /* { dg-additional-options "-ffast-math" } */
3 #include <assert.h>
4 #include <math.h>
6 #define N 10
7 #define N2 14
9 #define c1 1.2345f
10 #define c2 1.2345
12 #define DELTA 0.001
14 #define TEST_BIT_BUILTINS(T, S, S2) \
15 { \
16 T arguments[N2] \
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}; \
20 int clrsb[N2] = {}; \
21 int clz[N2] = {}; \
22 int ctz[N2] = {}; \
23 int ffs[N2] = {}; \
24 int parity[N2] = {}; \
25 int popcount[N2] = {}; \
27 _Pragma ("omp target map(to:clz[:N2], ctz[:N2], ffs[:N2], parity[:N2], popcount[:N2])") \
28 { \
29 for (unsigned i = 0; i < N2; i++) \
30 { \
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]); \
37 } \
38 } \
40 for (unsigned i = 0; i < N2; i++) \
41 { \
42 assert (clrsb[i] == __builtin_clrsb##S2 (arguments[i])); \
43 if (arguments[0] != 0) \
44 { \
45 assert (clz[i] == __builtin_clz##S2 (arguments[i])); \
46 assert (ctz[i] == __builtin_ctz##S2 (arguments[i])); \
47 } \
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])); \
51 } \
54 #define ASSERT(v1, v2) assert (fabs (v1 - v2) < DELTA)
56 int
57 main ()
59 float f[N] = {};
60 float d[N] = {};
62 /* 1) test direct mapping to HSA insns. */
64 #pragma omp target map(to: f[ : N], d[ : N])
66 f[0] = sinf (c1);
67 f[1] = cosf (c1);
68 f[2] = exp2f (c1);
69 f[3] = log2f (c1);
70 f[4] = truncf (c1);
71 f[5] = sqrtf (c1);
73 d[0] = trunc (c2);
74 d[1] = sqrt (c2);
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);
96 return 0;