[libc-commits] [libc] [libc][math][c++23] Add Fmabf16 math function (PR #182836)

via libc-commits libc-commits at lists.llvm.org
Mon Feb 23 04:13:53 PST 2026


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 origin/main HEAD --extensions h,cpp -- libc/src/math/fmabf16.h libc/src/math/generic/fmabf16.cpp libc/test/src/math/fmabf16_test.cpp libc/test/src/math/smoke/fmabf16_test.cpp libc/src/__support/FPUtil/bfloat16.h libc/src/__support/FPUtil/generic/FMA.h libc/src/__support/FPUtil/generic/add_sub.h libc/utils/MPFRWrapper/MPFRUtils.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/libc/src/math/generic/fmabf16.cpp b/libc/src/math/generic/fmabf16.cpp
index 233dbc908..ab221dd19 100644
--- a/libc/src/math/generic/fmabf16.cpp
+++ b/libc/src/math/generic/fmabf16.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/fmabf16.h"
-#include "src/__support/common.h"
 #include "src/__support/FPUtil/FMA.h"
 #include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/test/src/math/fmabf16_test.cpp b/libc/test/src/math/fmabf16_test.cpp
index 408a17c49..565225bcb 100644
--- a/libc/test/src/math/fmabf16_test.cpp
+++ b/libc/test/src/math/fmabf16_test.cpp
@@ -21,12 +21,8 @@ static constexpr uint16_t SUBNORM_NEG_START = 0x8001U;
 static constexpr uint16_t SUBNORM_NEG_STOP = 0x807FU;
 
 TEST_F(LlvmLibcFmaBf16Test, SubnormalNegativeRange) {
-  const bfloat16 z_values[] = {zero,
-                               neg_zero,
-                               inf,
-                               neg_inf,
-                               min_normal,
-                               max_normal};
+  const bfloat16 z_values[] = {zero,    neg_zero,   inf,
+                               neg_inf, min_normal, max_normal};
   for (uint16_t v1 = SUBNORM_NEG_START; v1 <= SUBNORM_NEG_STOP; v1++) {
     for (uint16_t v2 = SUBNORM_NEG_START; v2 <= SUBNORM_NEG_STOP; v2++) {
 
@@ -47,26 +43,13 @@ TEST_F(LlvmLibcFmaBf16Test, SubnormalNegativeRange) {
   }
 }
 
-
 TEST_F(LlvmLibcFmaBf16Test, SpecialNumbers) {
-  const bfloat16 z_values[] = {zero,
-                               neg_zero,
-                               inf,
-                               neg_inf,
-                               min_normal,
-                               max_normal};
-  const bfloat16 x_values[] = {zero,
-                               neg_zero,
-                               inf,
-                               neg_inf,
-                               min_normal,
-                               max_normal};
-  const bfloat16 y_values[] = {zero,
-                               neg_zero,
-                               inf,
-                               neg_inf,
-                               min_normal,
-                               max_normal};
+  const bfloat16 z_values[] = {zero,    neg_zero,   inf,
+                               neg_inf, min_normal, max_normal};
+  const bfloat16 x_values[] = {zero,    neg_zero,   inf,
+                               neg_inf, min_normal, max_normal};
+  const bfloat16 y_values[] = {zero,    neg_zero,   inf,
+                               neg_inf, min_normal, max_normal};
 
   for (bfloat16 x : x_values) {
     for (bfloat16 y : y_values) {
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 22617c0ee..4c5c891bc 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -764,10 +764,9 @@ compare_ternary_operation_one_output(Operation,
                                      double, RoundingMode);
 #endif
 
-template bool compare_ternary_operation_one_output(Operation,
-                                                   const TernaryInput<bfloat16> &,
-                                                   bfloat16, double,
-                                                   RoundingMode);
+template bool
+compare_ternary_operation_one_output(Operation, const TernaryInput<bfloat16> &,
+                                     bfloat16, double, RoundingMode);
 template bool compare_ternary_operation_one_output(Operation,
                                                    const TernaryInput<float> &,
                                                    bfloat16, double,

``````````

</details>


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


More information about the libc-commits mailing list