Skip to content

Commit 906b38f

Browse files
committed
minor updates
1 parent dd4785b commit 906b38f

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

libc/src/math/generic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,6 +4044,7 @@ add_entrypoint_object(
40444044
libc.hdr.errno_macros
40454045
libc.hdr.fenv_macros
40464046
libc.src.__support.FPUtil.cast
4047+
libc.src.__support.FPUtil.except_value_utils
40474048
libc.src.__support.FPUtil.fenv_impl
40484049
libc.src.__support.FPUtil.fp_bits
40494050
libc.src.__support.FPUtil.multiply_add

libc/src/math/generic/acosf16.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
namespace LIBC_NAMESPACE_DECL {
2323

2424
// Generated by Sollya using the following command:
25-
// > round(pi/2, D, RN);
26-
// > round(pi, D, RN);
27-
static constexpr float PI_2 = 0x1.921fb54442d18p0f;
28-
static constexpr float PI = 0x1.921fb54442d18p1f;
25+
// > round(pi/2, SG, RN);
26+
// > round(pi, SG, RN);
27+
static constexpr float PI_2 = 0x1.921fb6p0f;
28+
static constexpr float PI = 0x1.921fb6p1f;
2929

3030
static constexpr size_t N_EXCEPTS = 2;
3131

@@ -42,17 +42,6 @@ LLVM_LIBC_FUNCTION(float16, acosf16, (float16 x)) {
4242
uint16_t x_u = xbits.uintval();
4343
uint16_t x_abs = x_u & 0x7fff;
4444
uint16_t x_sign = x_u >> 15;
45-
float xf = x;
46-
47-
// Handle exceptional values
48-
if (auto r = ACOSF16_EXCEPTS.lookup(x_u); LIBC_UNLIKELY(r.has_value()))
49-
return r.value();
50-
51-
// |x| == 0x1p0, x is 1 or -1
52-
// if x is (-)1, return pi, else
53-
// if x is (+)1, return 0
54-
if (LIBC_UNLIKELY(x_abs == 0x3c00))
55-
return fputil::cast<float16>(x_sign ? 0x1.921fb54442d18p1 : 0.0f);
5645

5746
// |x| > 0x1p0, |x| > 1, or x is NaN.
5847
if (LIBC_UNLIKELY(x_abs > 0x3c00)) {
@@ -73,6 +62,18 @@ LLVM_LIBC_FUNCTION(float16, acosf16, (float16 x)) {
7362
return FPBits::quiet_nan().get_val();
7463
}
7564

65+
float xf = x;
66+
67+
// Handle exceptional values
68+
if (auto r = ACOSF16_EXCEPTS.lookup(x_u); LIBC_UNLIKELY(r.has_value()))
69+
return r.value();
70+
71+
// |x| == 0x1p0, x is 1 or -1
72+
// if x is (-)1, return pi, else
73+
// if x is (+)1, return 0
74+
if (LIBC_UNLIKELY(x_abs == 0x3c00))
75+
return fputil::cast<float16>(x_sign ? PI : 0.0f);
76+
7677
float xsq = xf * xf;
7778

7879
// |x| <= 0x1p-1, |x| <= 0.5

0 commit comments

Comments
 (0)