Revert builtins fp16 support: tests do not pass on Mac
[lldb.git] / compiler-rt / test / builtins / Unit / extendhfsf2_test.c
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_extendhfsf2
3
4 #include <stdio.h>
5
6 #include "fp_test.h"
7
8 float __extendhfsf2(uint16_t a);
9
10 int test__extendhfsf2(uint16_t a, float expected)
11 {
12     float x = __extendhfsf2(a);
13     int ret = compareResultH(x, expected);
14
15     if (ret){
16         printf("error in test__extendhfsf2(%#.4x) = %f, "
17                "expected %f\n", a, x, expected);
18     }
19     return ret;
20 }
21
22 char assumption_1[sizeof(__fp16) * CHAR_BIT == 16] = {0};
23
24 int main()
25 {
26     // qNaN
27     if (test__extendhfsf2(UINT16_C(0x7e00),
28                           makeQNaN32()))
29         return 1;
30     // NaN
31     if (test__extendhfsf2(UINT16_C(0x7e00),
32                           makeNaN32(UINT32_C(0x8000))))
33         return 1;
34     // inf
35     if (test__extendhfsf2(UINT16_C(0x7c00),
36                           makeInf32()))
37         return 1;
38     if (test__extendhfsf2(UINT16_C(0xfc00),
39                           -makeInf32()))
40         return 1;
41     // zero
42     if (test__extendhfsf2(UINT16_C(0x0),
43                           0.0f))
44         return 1;
45     if (test__extendhfsf2(UINT16_C(0x8000),
46                           -0.0f))
47         return 1;
48
49     if (test__extendhfsf2(UINT16_C(0x4248),
50                           3.1415926535f))
51         return 1;
52     if (test__extendhfsf2(UINT16_C(0xc248),
53                           -3.1415926535f))
54         return 1;
55     if (test__extendhfsf2(UINT16_C(0x7c00),
56                           0x1.987124876876324p+100f))
57         return 1;
58     if (test__extendhfsf2(UINT16_C(0x6e62),
59                           0x1.988p+12f))
60         return 1;
61     if (test__extendhfsf2(UINT16_C(0x3c00),
62                           0x1.0p+0f))
63         return 1;
64     if (test__extendhfsf2(UINT16_C(0x0400),
65                           0x1.0p-14f))
66         return 1;
67     // denormal
68     if (test__extendhfsf2(UINT16_C(0x0010),
69                           0x1.0p-20f))
70         return 1;
71     if (test__extendhfsf2(UINT16_C(0x0001),
72                           0x1.0p-24f))
73         return 1;
74     if (test__extendhfsf2(UINT16_C(0x8001),
75                           -0x1.0p-24f))
76         return 1;
77     if (test__extendhfsf2(UINT16_C(0x0001),
78                           0x1.5p-25f))
79         return 1;
80     // and back to zero
81     if (test__extendhfsf2(UINT16_C(0x0000),
82                           0x1.0p-25f))
83         return 1;
84     if (test__extendhfsf2(UINT16_C(0x8000),
85                           -0x1.0p-25f))
86         return 1;
87     // max (precise)
88     if (test__extendhfsf2(UINT16_C(0x7bff),
89                           65504.0f))
90         return 1;
91     // max (rounded)
92     if (test__extendhfsf2(UINT16_C(0x7bff),
93                           65504.0f))
94         return 1;
95     // max (to +inf)
96     if (test__extendhfsf2(UINT16_C(0x7c00),
97                           makeInf32()))
98         return 1;
99     if (test__extendhfsf2(UINT16_C(0xfc00),
100                           -makeInf32()))
101         return 1;
102     return 0;
103 }