1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_extendsftf2
3 
4 #include "int_lib.h"
5 #include <stdio.h>
6 
7 #if __LDBL_MANT_DIG__ == 113
8 
9 #include "fp_test.h"
10 
11 COMPILER_RT_ABI long double __extendsftf2(float a);
12 
test__extendsftf2(float a,uint64_t expectedHi,uint64_t expectedLo)13 int test__extendsftf2(float a, uint64_t expectedHi, uint64_t expectedLo)
14 {
15     long double x = __extendsftf2(a);
16     int ret = compareResultLD(x, expectedHi, expectedLo);
17 
18     if (ret)
19     {
20         printf("error in test__extendsftf2(%f) = %.20Lf, "
21                "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
22     }
23     return ret;
24 }
25 
26 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
27 
28 #endif
29 
main()30 int main()
31 {
32 #if __LDBL_MANT_DIG__ == 113
33     // qNaN
34     if (test__extendsftf2(makeQNaN32(),
35                           UINT64_C(0x7fff800000000000),
36                           UINT64_C(0x0)))
37         return 1;
38     // NaN
39     if (test__extendsftf2(makeNaN32(UINT32_C(0x410000)),
40                           UINT64_C(0x7fff820000000000),
41                           UINT64_C(0x0)))
42         return 1;
43     // inf
44     if (test__extendsftf2(makeInf32(),
45                           UINT64_C(0x7fff000000000000),
46                           UINT64_C(0x0)))
47         return 1;
48     // zero
49     if (test__extendsftf2(0.0f, UINT64_C(0x0), UINT64_C(0x0)))
50         return 1;
51 
52     if (test__extendsftf2(0x1.23456p+5f,
53                           UINT64_C(0x4004234560000000),
54                           UINT64_C(0x0)))
55         return 1;
56     if (test__extendsftf2(0x1.edcbap-9f,
57                           UINT64_C(0x3ff6edcba0000000),
58                           UINT64_C(0x0)))
59         return 1;
60     if (test__extendsftf2(0x1.23456p+45f,
61                           UINT64_C(0x402c234560000000),
62                           UINT64_C(0x0)))
63         return 1;
64     if (test__extendsftf2(0x1.edcbap-45f,
65                           UINT64_C(0x3fd2edcba0000000),
66                           UINT64_C(0x0)))
67         return 1;
68 
69 #else
70     printf("skipped\n");
71 
72 #endif
73     return 0;
74 }
75