1- // ===-- Half-precision acoshf16 function ----------------------------------- ===//
1+ // ===-- Half-precision acoshf16 function ----------------------------------===//
22//
33// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44// See https://llvm.org/LICENSE.txt for license information.
@@ -38,7 +38,7 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
3838 // Check for NaN input first.
3939 if (LIBC_UNLIKELY (xbits.is_nan ())) {
4040 if (xbits.is_signaling_nan ()) {
41- fputil::raise_except (FE_INVALID);
41+ fputil::raise_except_if_required (FE_INVALID);
4242 return FPBits::quiet_nan ().get_val ();
4343 }
4444 return x;
@@ -48,7 +48,7 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
4848 if (LIBC_UNLIKELY (xbits.is_inf ())) {
4949 if (xbits.is_neg ()) {
5050 fputil::set_errno_if_required (EDOM);
51- fputil::raise_except (FE_INVALID);
51+ fputil::raise_except_if_required (FE_INVALID);
5252 return FPBits::quiet_nan ().get_val ();
5353 }
5454 return x;
@@ -57,36 +57,36 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
5757 // Domain error for inputs less than 1.0.
5858 if (LIBC_UNLIKELY (x_abs < 0x3c00 )) {
5959 fputil::set_errno_if_required (EDOM);
60- fputil::raise_except (FE_INVALID);
60+ fputil::raise_except_if_required (FE_INVALID);
6161 return FPBits::quiet_nan ().get_val ();
6262 }
6363
6464 // acosh(1.0) exactly equals 0.0
65- if (LIBC_UNLIKELY (xbits. uintval () == 0x3c00U ))
65+ if (LIBC_UNLIKELY (x_u == 0x3c00U ))
6666 return float16 (0 .0f );
6767
6868 float xf32 = static_cast <float >(x);
6969
7070 // High precision for inputs very close to 1.0
71- if (LIBC_UNLIKELY (xf32 < 1 .25f )) {
72- float delta = xf32 - 1 .0f ;
73- float sqrt_2 = fputil::sqrt<float >(2 .0f * delta);
74- float sqrt_2d = fputil::sqrt<float >(2 .0f * delta);
75- float d32 = delta * fputil::sqrt<float >(delta);
76- float term2 = d32 / (6 .0f * fputil::sqrt<float >(2 .0f ));
77- float d52 = d32 * delta;
78- float term3 = 3 .0f * d52 / (80 .0f * sqrt_2);
79- float d72 = d52 * delta;
80- float term4 = 5 .0f * d72 / (1792 .0f * sqrt_2);
81- float result = sqrt_2d - term2 + term3 - term4;
82- return fputil::cast<float16>(result);
83- }
71+ // if (LIBC_UNLIKELY(xf32 < 1.25f)) {
72+ // float delta = xf32 - 1.0f;
73+ // float sqrt_2 = fputil::sqrt<float>(2.0f * delta);
74+ // float sqrt_2d = fputil::sqrt<float>(2.0f * delta);
75+ // float d32 = delta * fputil::sqrt<float>(delta);
76+ // float term2 = d32 / (6.0f * fputil::sqrt<float>(2.0f));
77+ // float d52 = d32 * delta;
78+ // float term3 = 3.0f * d52 / (80.0f * sqrt_2);
79+ // float d72 = d52 * delta;
80+ // float term4 = 5.0f * d72 / (1792.0f * sqrt_2);
81+ // float result = sqrt_2d - term2 + term3 - term4;
82+ // return fputil::cast<float16>(result);
83+ // }
8484
8585 // Special optimization for large input values.
86- if (LIBC_UNLIKELY (xf32 >= 32 .0f )) {
87- float result = static_cast <float >(log_eval (2 .0f * xf32));
88- return fputil::cast<float16>(result);
89- }
86+ // if (LIBC_UNLIKELY(xf32 >= 32.0f)) {
87+ // float result = static_cast<float>(log_eval(2.0f * xf32));
88+ // return fputil::cast<float16>(result);
89+ // }
9090
9191 // Standard computation for general case.
9292 float sqrt_term = fputil::sqrt<float >(fputil::multiply_add (xf32, xf32, -1 .0f ));
@@ -95,4 +95,4 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
9595 return fputil::cast<float16>(result);
9696}
9797
98- } // namespace LIBC_NAMESPACE_DECL
98+ } // namespace LIBC_NAMESPACE_DECL
0 commit comments