Skip to content

Commit 2cf37fe

Browse files
committed
[libc][math] Add except results.
1 parent 66c769a commit 2cf37fe

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libc/src/math/generic/atanhf16.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,23 @@
1414
#include "src/__support/FPUtil/FPBits.h"
1515
#include "src/__support/FPUtil/PolyEval.h"
1616
#include "src/__support/FPUtil/cast.h"
17+
#include "src/__support/FPUtil/except_value_utils.h"
1718
#include "src/__support/FPUtil/multiply_add.h"
1819
#include "src/__support/common.h"
1920
#include "src/__support/macros/config.h"
2021
#include "src/__support/macros/optimization.h"
2122

2223
namespace LIBC_NAMESPACE_DECL {
2324

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+
2434
LLVM_LIBC_FUNCTION(float16, atanhf16, (float16 x)) {
2535
using FPBits = fputil::FPBits<float16>;
2636

@@ -45,6 +55,10 @@ LLVM_LIBC_FUNCTION(float16, atanhf16, (float16 x)) {
4555
return FPBits::quiet_nan().get_val();
4656
}
4757

58+
if (auto r = ATANHF16_EXCEPTS.lookup(xbits.uintval());
59+
LIBC_UNLIKELY(r.has_value()))
60+
return r.value();
61+
4862
// For |x| less than approximately 0.10
4963
if (LIBC_UNLIKELY(x_abs <= 0x2e66U)) {
5064
// The Taylor expansion of atanh(x) is:

0 commit comments

Comments
 (0)