[libc] [llvm] Fix: Missed adding log10p1f16 to shared math (PR #189185)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 28 11:51:44 PDT 2026
https://github.com/Sukumarsawant created https://github.com/llvm/llvm-project/pull/189185
This PR intends to add the log10p1f16 function to shared math, along with adding tests for it and Bazel.
>From 7a828f1bdaa84e8ab4f2bae57d766b9113bee4ff Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 29 Mar 2026 00:20:00 +0530
Subject: [PATCH] fix:missed adding log10p1f16 to shared math
---
libc/shared/math.h | 1 +
libc/shared/math/log10p1f16.h | 29 +++++++++++++++++++
libc/test/shared/CMakeLists.txt | 1 +
libc/test/shared/shared_math_test.cpp | 1 +
.../llvm-project-overlay/libc/BUILD.bazel | 29 +++++++++++++++++++
5 files changed, 61 insertions(+)
create mode 100644 libc/shared/math/log10p1f16.h
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 71da66d37baba..38f0383f521be 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -185,6 +185,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 b807ea9ac602f..b63459ef5a98d 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -175,6 +175,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 31b14bbe204c7..666e0d1e05567 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -102,6 +102,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbf16(1.0f16));
EXPECT_FP_EQ(0x1p+0f16, LIBC_NAMESPACE::shared::log10f16(10.0f16));
+ EXPECT_FP_EQ(0x1p+0f16, LIBC_NAMESPACE::shared::log10p1f16(9.0f16));
EXPECT_FP_EQ(0x1p+0f16, LIBC_NAMESPACE::shared::log2f16(2.0f16));
EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::logbf16(1.0f16));
EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbf16(1.0f16));
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 29792cec1149e..cd8fdb29e5244 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -5233,6 +5233,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"],
@@ -7946,6 +7968,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 llvm-commits
mailing list