|
22 | 22 |
|
23 | 23 | namespace LIBC_NAMESPACE_DECL {
|
24 | 24 |
|
25 |
| -static constexpr size_t N_EXCEPTS = 4; |
| 25 | +static constexpr size_t N_EXCEPTS = 1; |
26 | 26 | static constexpr fputil::ExceptValues<float16, N_EXCEPTS> ATANHF16_EXCEPTS{{
|
27 | 27 | // (input, RZ output, RU offset, RD offset, RN offset)
|
28 | 28 | // x = 0x1.a5cp-4, atanhf16(x) = 0x1.a74p-4 (RZ)
|
29 | 29 | {0x2E97, 0x2E9D, 1, 0, 0},
|
30 |
| - // x = -0x1.a5cp-4, atanhf16(x) = -0x1.a74p-4 (RZ) |
31 |
| - {0xAE97, 0xAE9D, 0, 1, 0}, |
32 |
| - // x = -0x1.99cp-4, atanhf16(x) = -0x1.9bp-4 (RZ) |
33 |
| - {0xAE67, 0xAE6C, 0, 1, 1}, |
34 |
| - // x = -0x1.b8cp-3, atanhf16(x) = -0x1.bfcp-3 (RZ) |
35 |
| - {0xB2E3, 0xB2FF, 0, 1, 0}, |
36 | 30 | }};
|
37 | 31 |
|
38 | 32 | LLVM_LIBC_FUNCTION(float16, atanhf16, (float16 x)) {
|
@@ -76,9 +70,9 @@ LLVM_LIBC_FUNCTION(float16, atanhf16, (float16 x)) {
|
76 | 70 | // The Taylor expansion of atanh(x) is:
|
77 | 71 | // atanh(x) = x + x^3/3 + x^5/5 + x^7/7 + x^9/9 + x^11/11
|
78 | 72 | // = x * [1 + x^2/3 + x^4/5 + x^6/7 + x^8/9 + x^10/11]
|
79 |
| - // When |x| < 2^-16, this can be approximated by: |
| 73 | + // When |x| < 2^-6 (0x2400U), this can be approximated by: |
80 | 74 | // atanh(x) ≈ x + (1/3)*x^3
|
81 |
| - if (LIBC_UNLIKELY(x_abs < 0x0100U)) { |
| 75 | + if (LIBC_UNLIKELY(x_abs < 0x2400U)) { |
82 | 76 | float xf = x;
|
83 | 77 | return fputil::cast<float16>(xf + 0x1.555556p-2f * xf * xf * xf);
|
84 | 78 | }
|
|
0 commit comments