[libc-commits] [libc] [llvm] Fix: Missed adding log10p1f16 to shared math (PR #189179)
via libc-commits
libc-commits at lists.llvm.org
Sat Mar 28 10:00:35 PDT 2026
https://github.com/Sukumarsawant created https://github.com/llvm/llvm-project/pull/189179
This PR intends to add the log10p1f16 function to shared math, along with adding tests for it and bazel.
>From 1d82cd6b721beaaaee81def906edf8828cc37dbe Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sat, 28 Mar 2026 22:28:09 +0530
Subject: [PATCH] fix: missed making it shared
---
libc/shared/math.h | 1 +
libc/shared/math/log2p1f16.h | 29 +++++++++++++++++++
libc/test/shared/CMakeLists.txt | 1 +
libc/test/shared/shared_math_test.cpp | 1 +
.../llvm-project-overlay/libc/BUILD.bazel | 28 ++++++++++++++++++
5 files changed, 60 insertions(+)
create mode 100644 libc/shared/math/log2p1f16.h
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 71da66d37baba..29ad8467478eb 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -190,6 +190,7 @@
#include "math/log2.h"
#include "math/log2f.h"
#include "math/log2f16.h"
+#include "math/log2p1f16.h"
#include "math/log_bf16.h"
#include "math/logb.h"
#include "math/logbf.h"
diff --git a/libc/shared/math/log2p1f16.h b/libc/shared/math/log2p1f16.h
new file mode 100644
index 0000000000000..b5ad3fe45e1dd
--- /dev/null
+++ b/libc/shared/math/log2p1f16.h
@@ -0,0 +1,29 @@
+//===-- Shared log2p1f16 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_LOG2P1F16_H
+#define LLVM_LIBC_SHARED_MATH_LOG2P1F16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/log2p1f16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::log2p1f16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_LOG2P1F16_H
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index b807ea9ac602f..d1bb4dbc4f413 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -182,6 +182,7 @@ add_fp_unittest(
libc.src.__support.math.logb
libc.src.__support.math.log2f
libc.src.__support.math.log2f16
+ libc.src.__support.math.log2p1f16
libc.src.__support.math.logbf
libc.src.__support.math.logbf128
libc.src.__support.math.logbf16
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 31b14bbe204c7..463c9bbd5a9da 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -103,6 +103,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::log2f16(2.0f16));
+ EXPECT_FP_EQ(0x1p+0f16, LIBC_NAMESPACE::shared::log2p1f16(1.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..2e9354f2a81bf 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -5272,6 +5272,27 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_log2p1f16",
+ hdrs = ["src/__support/math/log2p1f16.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_expxf16_utils",
+ ":hdr_errno_macros",
+ ":hdr_fenv_macros",
+ ":llvm_libc_macros_float16_macros",
+ ],
+)
+
libc_support_library(
name = "__support_math_log2f",
hdrs = ["src/__support/math/log2f.h"],
@@ -7977,6 +7998,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "log2p1f16",
+ additional_deps = [
+ ":__support_math_log2p1f16",
+ ],
+)
+
libc_math_function(
name = "logb",
additional_deps = [
More information about the libc-commits
mailing list