1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_floattisf
4 //===-- floattisf_test.c - Test __floattisf -------------------------------===//
6 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
7 // See https://llvm.org/LICENSE.txt for license information.
8 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10 //===----------------------------------------------------------------------===//
12 // This file tests __floattisf for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
22 // Returns: convert a to a float, rounding toward even.
24 // Assumption: float is a IEEE 32 bit floating point type
25 // ti_int is a 64 bit integral type
27 // seee eeee emmm mmmm mmmm mmmm mmmm mmmm
29 COMPILER_RT_ABI
float __floattisf(ti_int a
);
31 int test__floattisf(ti_int a
, float expected
)
33 float x
= __floattisf(a
);
38 printf("error in __floattisf(0x%.16llX%.16llX) = %a, expected %a\n",
39 at
.s
.high
, at
.s
.low
, x
, expected
);
44 char assumption_1
[sizeof(ti_int
) == 2*sizeof(di_int
)] = {0};
45 char assumption_2
[sizeof(ti_int
)*CHAR_BIT
== 128] = {0};
46 char assumption_3
[sizeof(float)*CHAR_BIT
== 32] = {0};
53 if (test__floattisf(0, 0.0F
))
56 if (test__floattisf(1, 1.0F
))
58 if (test__floattisf(2, 2.0F
))
60 if (test__floattisf(-1, -1.0F
))
62 if (test__floattisf(-2, -2.0F
))
65 if (test__floattisf(0x7FFFFF8000000000LL
, 0x1.FFFFFEp
+62F
))
67 if (test__floattisf(0x7FFFFF0000000000LL
, 0x1.FFFFFCp
+62F
))
70 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000008000000000LL
),
73 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000010000000000LL
),
77 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000000LL
),
80 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
),
84 if (test__floattisf(0x0007FB72E8000000LL
, 0x1.FEDCBAp
+50F
))
87 if (test__floattisf(0x0007FB72EA000000LL
, 0x1.FEDCBAp
+50F
))
89 if (test__floattisf(0x0007FB72EB000000LL
, 0x1.FEDCBAp
+50F
))
91 if (test__floattisf(0x0007FB72EBFFFFFFLL
, 0x1.FEDCBAp
+50F
))
93 if (test__floattisf(0x0007FB72EC000000LL
, 0x1.FEDCBCp
+50F
))
95 if (test__floattisf(0x0007FB72E8000001LL
, 0x1.FEDCBAp
+50F
))
98 if (test__floattisf(0x0007FB72E6000000LL
, 0x1.FEDCBAp
+50F
))
100 if (test__floattisf(0x0007FB72E7000000LL
, 0x1.FEDCBAp
+50F
))
102 if (test__floattisf(0x0007FB72E7FFFFFFLL
, 0x1.FEDCBAp
+50F
))
104 if (test__floattisf(0x0007FB72E4000001LL
, 0x1.FEDCBAp
+50F
))
106 if (test__floattisf(0x0007FB72E4000000LL
, 0x1.FEDCB8p
+50F
))
109 if (test__floattisf(make_ti(0x0007FB72E8000000LL
, 0), 0x1.FEDCBAp
+114F
))
112 if (test__floattisf(make_ti(0x0007FB72EA000000LL
, 0), 0x1.FEDCBAp
+114F
))
114 if (test__floattisf(make_ti(0x0007FB72EB000000LL
, 0), 0x1.FEDCBAp
+114F
))
116 if (test__floattisf(make_ti(0x0007FB72EBFFFFFFLL
, 0), 0x1.FEDCBAp
+114F
))
118 if (test__floattisf(make_ti(0x0007FB72EC000000LL
, 0), 0x1.FEDCBCp
+114F
))
120 if (test__floattisf(make_ti(0x0007FB72E8000001LL
, 0), 0x1.FEDCBAp
+114F
))
123 if (test__floattisf(make_ti(0x0007FB72E6000000LL
, 0), 0x1.FEDCBAp
+114F
))
125 if (test__floattisf(make_ti(0x0007FB72E7000000LL
, 0), 0x1.FEDCBAp
+114F
))
127 if (test__floattisf(make_ti(0x0007FB72E7FFFFFFLL
, 0), 0x1.FEDCBAp
+114F
))
129 if (test__floattisf(make_ti(0x0007FB72E4000001LL
, 0), 0x1.FEDCBAp
+114F
))
131 if (test__floattisf(make_ti(0x0007FB72E4000000LL
, 0), 0x1.FEDCB8p
+114F
))