1818
1919namespace LIBC_NAMESPACE_DECL {
2020
21- static constexpr size_t N_EXCEPTS = 1 ;
21+ static constexpr size_t N_EXCEPTS = 2 ;
2222static constexpr fputil::ExceptValues<float16, N_EXCEPTS> ACOSHF16_EXCEPTS{
2323 {// (input, RZ output, RU offset, RD offset, RN offset)
24- {0x41B7 , 0x3ED8 , 0 , 1 , 0 }}};
24+ {0x41B7 , 0x3ED8 , 1 , 0 , 0 },
25+ {0x3CE4 , 0x393E , 1 , 0 , 1 }}};
2526
2627LLVM_LIBC_FUNCTION (float16, acoshf16, (float16 x)) {
2728 using FPBits = fputil::FPBits<float16>;
@@ -59,8 +60,11 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
5960 if (LIBC_UNLIKELY (x_u == 0x3c00U ))
6061 return float16 (0 .0f );
6162
62- float xf32 = x;
63+ if (auto r = ACOSHF16_EXCEPTS.lookup (xbits.uintval ());
64+ LIBC_UNLIKELY (r.has_value ()))
65+ return r.value ();
6366
67+ float xf32 = x;
6468 // High precision for inputs very close to 1.0
6569 if (LIBC_UNLIKELY (xf32 < 1 .25f )) {
6670 float delta = xf32 - 1 .0f ;
@@ -73,10 +77,6 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
7377 return fputil::cast<float16>(approx);
7478 }
7579
76- if (auto r = ACOSHF16_EXCEPTS.lookup (xbits.uintval ());
77- LIBC_UNLIKELY (r.has_value ()))
78- return r.value ();
79-
8080 // Standard computation for general case.
8181 float sqrt_term =
8282 fputil::sqrt<float >(fputil::multiply_add (xf32, xf32, -1 .0f ));
0 commit comments