[libc-commits] [libc] [llvm] [libc][math] Fix: Missed adding log2p1f16 to shared math (PR #189179)
via libc-commits
libc-commits at lists.llvm.org
Sun Apr 12 14:43:37 PDT 2026
https://github.com/Sukumarsawant updated https://github.com/llvm/llvm-project/pull/189179
>From 4ec3e4d917a4d97828d0d65f153085823ed94cc6 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 12a3e2cc546ba..0c126ae9ebff7 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -193,6 +193,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 829a92be0019e..6494ceca5e90f 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -185,6 +185,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 8a60bdcbad095..dedf9923fdd88 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -55,6 +55,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::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));
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 692f4ebbca32b..fe0db7d76af70 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -5293,6 +5293,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"],
@@ -8017,6 +8038,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