1 // RUN: %clang_builtins %s %librt -o %t && %run %t
9 // Since we are comparing the compiler-rt IEEE implementation against libc's
10 // long double implementation, this test can only succeed if long double
11 // is an IEEE 128-bit floating point number.
12 #if defined(CRT_HAS_TF_MODE) && defined(CRT_LDBL_IEEE_F128)
14 int test__compiler_rt_fmaxl(fp_t x
, fp_t y
) {
15 fp_t crt_value
= __compiler_rt_fmaxl(x
, y
);
16 fp_t libm_value
= fmaxl(x
, y
);
17 // Consider +0 and -0 equal, and also disregard the sign/payload of two NaNs.
18 if (crt_value
!= libm_value
&&
19 !(crt_isnan(crt_value
) && crt_isnan(libm_value
))) {
20 // Split expected values into two for printf
21 twords x_t
, y_t
, crt_value_t
, libm_value_t
;
24 crt_value_t
.all
= toRep(crt_value
);
25 libm_value_t
.all
= toRep(libm_value
);
27 "error: in __compiler_rt_fmaxl([%llX %llX], [%llX %llX]) = "
28 "[%llX %llX] != [%llX %llX]\n",
29 (unsigned long long)x_t
.s
.high
, (unsigned long long)x_t
.s
.low
,
30 (unsigned long long)y_t
.s
.high
, (unsigned long long)y_t
.s
.low
,
31 (unsigned long long)crt_value_t
.s
.high
,
32 (unsigned long long)crt_value_t
.s
.low
,
33 (unsigned long long)libm_value_t
.s
.high
,
34 (unsigned long long)libm_value_t
.s
.low
);
41 -NAN
, NAN
, -INFINITY
, INFINITY
, -0.0, 0.0, -1, 1, -2, 2,
42 -0x1.0p
-16383L, 0x1.0p
-16383L, -0x1.0p
-16384L, 0x1.0p
-16384L, // subnormals
43 -1.001, 1.001, -1.002, 1.002,
47 const unsigned N
= sizeof(cases
) / sizeof(cases
[0]);
49 for (i
= 0; i
< N
; ++i
) {
50 for (j
= 0; j
< N
; ++j
) {
51 if (test__compiler_rt_fmaxl(cases
[i
], cases
[j
])) return 1;