2222namespace 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
3030static 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