[libc-commits] [libc] [libc][math][c23] Add acoshf16 C23 math function. (PR #130588)

via libc-commits libc-commits at lists.llvm.org
Mon Mar 10 05:09:19 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 2172a5edcf9357d24006a3c1032f2d52e199915d af894d520af60d751e06f48ab7d003b63f27d671 --extensions h,cpp -- libc/src/math/acoshf16.h libc/src/math/generic/acoshf16.cpp libc/test/src/math/acoshf16_test.cpp libc/test/src/math/smoke/acoshf16_test.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/math/acoshf16.h b/libc/src/math/acoshf16.h
index a23426ffe5..b68dc10f8e 100644
--- a/libc/src/math/acoshf16.h
+++ b/libc/src/math/acoshf16.h
@@ -1,4 +1,5 @@
-//===-- Implementation header for acoshf16 -----------------------*- C++ -*-===//
+//===-- Implementation header for acoshf16 -----------------------*- 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/acoshf16.cpp b/libc/src/math/generic/acoshf16.cpp
index 01f97f536c..059780b740 100644
--- a/libc/src/math/generic/acoshf16.cpp
+++ b/libc/src/math/generic/acoshf16.cpp
@@ -1,4 +1,5 @@
-//===-- Half-precision acoshf16 function -----------------------------------===//
+//===-- Half-precision acoshf16 function
+//-----------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,9 +12,9 @@
 #include "hdr/fenv_macros.h"
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/sqrt.h"
-#include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/sqrt.h"
 #include "src/__support/macros/optimization.h"
 #include "src/math/generic/explogxf.h"
 
@@ -43,8 +44,8 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
   // Compute in float32 for accuracy
   float xf32 = static_cast<float>(x);
   // sqrt(x^2 - 1)
-  float sqrt_term = fputil::sqrt<float>(
-      fputil::multiply_add(xf32, xf32, -1.0f));
+  float sqrt_term =
+      fputil::sqrt<float>(fputil::multiply_add(xf32, xf32, -1.0f));
 
   // log(x + sqrt(x^2 - 1))
   float result = static_cast<float>(log_eval(xf32 + sqrt_term));
diff --git a/libc/test/src/math/acoshf16_test.cpp b/libc/test/src/math/acoshf16_test.cpp
index d4ebef87f3..09f1a0144b 100644
--- a/libc/test/src/math/acoshf16_test.cpp
+++ b/libc/test/src/math/acoshf16_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for acoshf16 ---------------------------------------------===//
+//===-- Unittests for acoshf16
+//---------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -24,7 +25,8 @@ TEST_F(LlvmLibcAcoshf16Test, SpecialNumbers) {
   EXPECT_MATH_ERRNO(0);
 
   // acoshf16(1.0) = 0
-  EXPECT_FP_EQ_ALL_ROUNDING(float16(0.0f), LIBC_NAMESPACE::acoshf16(float16(1.0f)));
+  EXPECT_FP_EQ_ALL_ROUNDING(float16(0.0f),
+                            LIBC_NAMESPACE::acoshf16(float16(1.0f)));
   EXPECT_MATH_ERRNO(0);
 
   // Domain error (x < 1)

``````````

</details>


https://github.com/llvm/llvm-project/pull/130588


More information about the libc-commits mailing list