14
14
#include " src/__support/FPUtil/FPBits.h"
15
15
#include " src/__support/FPUtil/PolyEval.h"
16
16
#include " src/__support/FPUtil/cast.h"
17
+ #include " src/__support/FPUtil/except_value_utils.h"
17
18
#include " src/__support/FPUtil/multiply_add.h"
18
19
#include " src/__support/common.h"
19
20
#include " src/__support/macros/config.h"
20
21
#include " src/__support/macros/optimization.h"
21
22
22
23
namespace LIBC_NAMESPACE_DECL {
23
24
25
+ static constexpr size_t N_EXCEPTS = 2 ;
26
+ static constexpr fputil::ExceptValues<float16, N_EXCEPTS> ATANHF16_EXCEPTS{{
27
+ // (input, RZ output, RU offset, RD offset, RN offset)
28
+ // x = 0x1.a5cp-4, acoshf16(x) = 0x1.a74p-4 (RZ)
29
+ {0x2E97 , 0x2E9D , 1 , 0 , 0 },
30
+ // x = -0x1.a5cp-4, acoshf16(x) = -0x1.a74p-4 (RZ)
31
+ {0xAE97 , 0xAE9D , 0 , 1 , 0 },
32
+ }};
33
+
24
34
LLVM_LIBC_FUNCTION (float16, atanhf16, (float16 x)) {
25
35
using FPBits = fputil::FPBits<float16>;
26
36
@@ -45,6 +55,10 @@ LLVM_LIBC_FUNCTION(float16, atanhf16, (float16 x)) {
45
55
return FPBits::quiet_nan ().get_val ();
46
56
}
47
57
58
+ if (auto r = ATANHF16_EXCEPTS.lookup (xbits.uintval ());
59
+ LIBC_UNLIKELY (r.has_value ()))
60
+ return r.value ();
61
+
48
62
// For |x| less than approximately 0.10
49
63
if (LIBC_UNLIKELY (x_abs <= 0x2e66U )) {
50
64
// The Taylor expansion of atanh(x) is:
0 commit comments