[libc-commits] [libc] bdc1192 - [libc][math] Fix: add log10p1f16 to shared math (#189185)

via libc-commits libc-commits at lists.llvm.org
Mon Apr 13 02:00:08 PDT 2026


Author: Zorojuro
Date: 2026-04-13T11:00:03+02:00
New Revision: bdc11929aa0b4dbcd0f06ade1bc54b45b5b8bf8b

URL: https://github.com/llvm/llvm-project/commit/bdc11929aa0b4dbcd0f06ade1bc54b45b5b8bf8b
DIFF: https://github.com/llvm/llvm-project/commit/bdc11929aa0b4dbcd0f06ade1bc54b45b5b8bf8b.diff

LOG: [libc][math] Fix: add log10p1f16 to shared math (#189185)

This PR intends to add the log10p1f16 function to shared math, along
with adding tests for it and Bazel which was missed in
[a7d1a87](https://github.com/llvm/llvm-project/commit/a7d1a87b30ce626678d33fe1c12e647f7ce4fb20).

Added: 
    libc/shared/math/log10p1f16.h

Modified: 
    libc/shared/math.h
    libc/test/shared/CMakeLists.txt
    libc/test/shared/shared_math_test.cpp
    utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Removed: 
    


################################################################################
diff  --git a/libc/shared/math.h b/libc/shared/math.h
index 0c126ae9ebff7..275b89db3179a 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -188,6 +188,7 @@
 #include "math/log10.h"
 #include "math/log10f.h"
 #include "math/log10f16.h"
+#include "math/log10p1f16.h"
 #include "math/log1p.h"
 #include "math/log1pf.h"
 #include "math/log2.h"

diff  --git a/libc/shared/math/log10p1f16.h b/libc/shared/math/log10p1f16.h
new file mode 100644
index 0000000000000..db1ee4cd699ff
--- /dev/null
+++ b/libc/shared/math/log10p1f16.h
@@ -0,0 +1,29 @@
+//===-- Shared log10p1f16 function ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LOG10P1F16_H
+#define LLVM_LIBC_SHARED_MATH_LOG10P1F16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/log10p1f16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::log10p1f16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_LOG10P1F16_H

diff  --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 6494ceca5e90f..9c4b7edb377e2 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -178,6 +178,7 @@ add_fp_unittest(
     libc.src.__support.math.log
     libc.src.__support.math.log10
     libc.src.__support.math.log10f16
+    libc.src.__support.math.log10p1f16
     libc.src.__support.math.log10f
     libc.src.__support.math.log1p
     libc.src.__support.math.log1pf

diff  --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index dedf9923fdd88..4c58c834960ed 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -54,6 +54,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
 
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbf16(1.0f16));
   EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::log10f16(10.0f16));
+  EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::log10p1f16(9.0f16));
   EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::log2f16(2.0f16));
   EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::log2p1f16(1.0f16));
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::logbf16(1.0f16));

diff  --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index fe0db7d76af70..3f56367efff51 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -5254,6 +5254,28 @@ libc_support_library(
     ],
 )
 
+libc_support_library(
+    name = "__support_math_log10p1f16",
+    hdrs = ["src/__support/math/log10p1f16.h"],
+    deps = [
+        ":__support_common",
+        ":__support_fputil_cast",
+        ":__support_fputil_except_value_utils",
+        ":__support_fputil_fenv_impl",
+        ":__support_fputil_fp_bits",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_poly_eval",
+        ":__support_macros_config",
+        ":__support_macros_optimization",
+        ":__support_macros_properties_cpu_features",
+        ":__support_math_exp10_float16_constants",
+        ":__support_math_expxf16_utils",
+        ":hdr_errno_macros",
+        ":hdr_fenv_macros",
+        ":llvm_libc_macros_float16_macros",
+    ],
+)
+
 libc_support_library(
     name = "__support_math_log10f",
     hdrs = ["src/__support/math/log10f.h"],
@@ -8007,6 +8029,13 @@ libc_math_function(
     ],
 )
 
+libc_math_function(
+    name = "log10p1f16",
+    additional_deps = [
+        ":__support_math_log10p1f16",
+    ],
+)
+
 libc_math_function(
     name = "log1p",
     additional_deps = [":__support_math_log1p"],


        


More information about the libc-commits mailing list