Skip to content

Commit e79d2ce

Browse files
committed
Cleaned up rounding logic
1 parent e7ef314 commit e79d2ce

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

libc/src/math/generic/asinhf16.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "src/__support/FPUtil/cast.h"
1313
#include "src/__support/FPUtil/except_value_utils.h"
1414
#include "src/__support/FPUtil/multiply_add.h"
15+
#include "src/__support/FPUtil/rounding_mode.h"
1516
#include "src/__support/FPUtil/sqrt.h"
1617
#include "src/__support/common.h"
1718
#include "src/__support/macros/config.h"
@@ -76,13 +77,10 @@ LLVM_LIBC_FUNCTION(float16, asinhf16, (float16 x)) {
7677
// when |x| < 0x1.718p-5, asinhf16(x) = x. Adjust by 1 ULP for certain
7778
// rounding types.
7879
if (LIBC_UNLIKELY(x_abs < 0x29c6)) {
79-
if (((fputil::get_round() == FE_UPWARD) ||
80-
(fputil::get_round() == FE_TOWARDZERO)) &&
81-
xf < 0)
80+
int rounding = fputil::quick_get_round();
81+
if ((rounding == FE_UPWARD || rounding == FE_TOWARDZERO) && xf < 0)
8282
return fputil::cast<float16>(xf + 0x1p-24f);
83-
if (((fputil::get_round() == FE_DOWNWARD) ||
84-
(fputil::get_round() == FE_TOWARDZERO)) &&
85-
xf > 0)
83+
if ((rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO) && xf > 0)
8684
return fputil::cast<float16>(xf - 0x1p-24f);
8785
return fputil::cast<float16>(xf);
8886
}
@@ -103,4 +101,5 @@ LLVM_LIBC_FUNCTION(float16, asinhf16, (float16 x)) {
103101
return fputil::cast<float16>(
104102
x_sign * log_eval(fputil::multiply_add(xf, x_sign, sqrt_term)));
105103
}
104+
106105
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)