[libc-commits] [libc] [libc][math][c23] Add asinhf16() function (PR #131351)
via libc-commits
libc-commits at lists.llvm.org
Fri Mar 14 09:28:49 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 389ed474e81f402294a1dc03a5ea7b039a523965 75ec8ec56aafe9c38fecde76ff175979a494b503 --extensions cpp,h -- libc/src/math/asinhf16.h libc/src/math/generic/asinhf16.cpp libc/test/src/math/asinhf16_test.cpp libc/test/src/math/smoke/asinhf16_test.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libc/src/math/asinhf16.h b/libc/src/math/asinhf16.h
index 2969a34981..610b37b885 100644
--- a/libc/src/math/asinhf16.h
+++ b/libc/src/math/asinhf16.h
@@ -1,4 +1,5 @@
-//===-- Implementation header for asinhf16 -----------------------*- C++ -*-===//
+//===-- Implementation header for asinhf16 -----------------------*- C++
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/math/generic/asinhf16.cpp b/libc/src/math/generic/asinhf16.cpp
index d8a6058623..34e2a90d83 100644
--- a/libc/src/math/generic/asinhf16.cpp
+++ b/libc/src/math/generic/asinhf16.cpp
@@ -1,4 +1,5 @@
-//===-- Half-precision asinhf16(x) function --------------------------------===//
+//===-- Half-precision asinhf16(x) function
+//--------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,30 +9,29 @@
//===----------------------------------------------------------------------===//
#include "src/math/asinhf16.h"
-#include "src/math/generic/explogxf.h"
#include "src/__support/FPUtil/except_value_utils.h"
#include "src/__support/FPUtil/generic/sqrt.h"
#include "src/__support/FPUtil/multiply_add.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
+#include "src/math/generic/explogxf.h"
namespace LIBC_NAMESPACE_DECL {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
static constexpr size_t N_EXCEPTS = 8;
-static constexpr fputil::ExceptValues<float16, N_EXCEPTS> ASINHF16_EXCEPTS{{
- // (input, RZ output, RU offset, RD offset, RN offset)
- {0x3769, 0x372A, 1, 0, 1},
- {0x3B5B, 0x3A96, 1, 0, 0},
- {0x4B1F, 0x42B3, 1, 0, 0},
- {0x4C9B, 0x4336, 1, 0, 1},
- {0xB769, 0xB72A, 0, 1, 1},
- {0xBB5B, 0xBA96, 0, 1, 0},
- {0xCB1F, 0xC2B3, 0, 1, 0},
- {0xCC9B, 0xC336, 0, 1, 1}
-}};
+static constexpr fputil::ExceptValues<float16, N_EXCEPTS> ASINHF16_EXCEPTS{
+ {// (input, RZ output, RU offset, RD offset, RN offset)
+ {0x3769, 0x372A, 1, 0, 1},
+ {0x3B5B, 0x3A96, 1, 0, 0},
+ {0x4B1F, 0x42B3, 1, 0, 0},
+ {0x4C9B, 0x4336, 1, 0, 1},
+ {0xB769, 0xB72A, 0, 1, 1},
+ {0xBB5B, 0xBA96, 0, 1, 0},
+ {0xCB1F, 0xC2B3, 0, 1, 0},
+ {0xCC9B, 0xC336, 0, 1, 1}}};
#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
LLVM_LIBC_FUNCTION(float16, asinhf16, (float16 x)) {
@@ -64,8 +64,8 @@ LLVM_LIBC_FUNCTION(float16, asinhf16, (float16 x)) {
if (LIBC_UNLIKELY(x_abs <= 0x3400)) {
if (LIBC_UNLIKELY(x_abs == 0))
return x;
- if (LIBC_UNLIKELY((fputil::get_round() == FE_UPWARD) &&
- (x_u >= 0x8401) && (x_u <= 0x90E6)))
+ if (LIBC_UNLIKELY((fputil::get_round() == FE_UPWARD) && (x_u >= 0x8401) &&
+ (x_u <= 0x90E6)))
return static_cast<float16>(x_d + 0x1p-24f);
float x_sq = x_d * x_d;
@@ -79,7 +79,7 @@ LLVM_LIBC_FUNCTION(float16, asinhf16, (float16 x)) {
// General case: asinh(x) = ln(x + sqrt(x^2 + 1))
float sqrt_term = fputil::sqrt<float>(fputil::multiply_add(x_d, x_d, 1.0f));
- return fputil::cast<float16>(x_sign * log_eval(
- fputil::multiply_add(x_d, x_sign, sqrt_term)));
-}
+ return fputil::cast<float16>(
+ x_sign * log_eval(fputil::multiply_add(x_d, x_sign, sqrt_term)));
}
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/math/asinhf16_test.cpp b/libc/test/src/math/asinhf16_test.cpp
index 32f3aa141d..f5f4f47e80 100644
--- a/libc/test/src/math/asinhf16_test.cpp
+++ b/libc/test/src/math/asinhf16_test.cpp
@@ -1,4 +1,5 @@
-//===-- Exhaustive test for asinhf16 ---------------------------------------===//
+//===-- Exhaustive test for asinhf16
+//---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/math/smoke/asinhf16_test.cpp b/libc/test/src/math/smoke/asinhf16_test.cpp
index 6faac38067..d3c3251465 100644
--- a/libc/test/src/math/smoke/asinhf16_test.cpp
+++ b/libc/test/src/math/smoke/asinhf16_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for asinhf16 ----------------------------------------------===//
+//===-- Unittests for asinhf16
+//----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
``````````
</details>
https://github.com/llvm/llvm-project/pull/131351
More information about the libc-commits
mailing list