1212#include " hdr/fenv_macros.h"
1313#include " src/__support/FPUtil/FEnvImpl.h"
1414#include " src/__support/FPUtil/FPBits.h"
15+ #include " src/__support/FPUtil/PolyEval.h"
1516#include " src/__support/FPUtil/cast.h"
1617#include " src/__support/FPUtil/except_value_utils.h"
1718#include " src/__support/FPUtil/multiply_add.h"
1819#include " src/__support/FPUtil/sqrt.h"
20+ #include " src/__support/common.h"
21+ #include " src/__support/macros/config.h"
1922#include " src/__support/macros/optimization.h"
2023
2124namespace LIBC_NAMESPACE_DECL {
@@ -34,15 +37,6 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
3437 FPBits xbits (x);
3538 uint16_t x_u = xbits.uintval ();
3639
37- // Domain error for inputs less than 1.0.
38- if (LIBC_UNLIKELY (x <= 1 .0f )) {
39- if (x == 1 .0f )
40- return FPBits::zero ().get_val ();
41- fputil::set_errno_if_required (EDOM);
42- fputil::raise_except_if_required (FE_INVALID);
43- return FPBits::quiet_nan ().get_val ();
44- }
45-
4640 // Check for NaN input first.
4741 if (LIBC_UNLIKELY (xbits.is_inf_or_nan ())) {
4842 if (xbits.is_signaling_nan ()) {
@@ -57,6 +51,15 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
5751 return x;
5852 }
5953
54+ // Domain error for inputs less than 1.0.
55+ if (LIBC_UNLIKELY (x <= 1 .0f )) {
56+ if (x == 1 .0f )
57+ return FPBits::zero ().get_val ();
58+ fputil::set_errno_if_required (EDOM);
59+ fputil::raise_except_if_required (FE_INVALID);
60+ return FPBits::quiet_nan ().get_val ();
61+ }
62+
6063 if (auto r = ACOSHF16_EXCEPTS.lookup (xbits.uintval ());
6164 LIBC_UNLIKELY (r.has_value ()))
6265 return r.value ();
0 commit comments