[libc-commits] [libc] [llvm] [libc][math] Implement log1pf16 (C23) (PR #224152)
Usef Ahmed via libc-commits
libc-commits at lists.llvm.org
Fri Oct 23 11:48:16 PDT 2026
https://github.com/usefahmed07 updated https://github.com/llvm/llvm-project/pull/224152
>From 7537975258aa58ef30f1d45b44fb6768c4e8d055 Mon Sep 17 00:00:00 2001
From: usefahmed07 <youssef.ahmed.hamaza at gmail.com>
Date: Thu, 17 Sep 2026 01:32:02 +0300
Subject: [PATCH 1/9] [libc][math] Add ExceptValues table for log1pf16
hard-to-round cases
Fixes #189543
---
libc/config/linux/x86_64/entrypoints.txt | 1 +
libc/src/__support/math/log1pf16.h | 141 +++++++++++++++++++++++
libc/src/math/CMakeLists.txt | 1 +
libc/src/math/generic/CMakeLists.txt | 11 ++
libc/src/math/generic/log1pf16.cpp | 18 +++
libc/src/math/log1pf16.h | 21 ++++
6 files changed, 193 insertions(+)
create mode 100644 libc/src/__support/math/log1pf16.h
create mode 100644 libc/src/math/generic/log1pf16.cpp
create mode 100644 libc/src/math/log1pf16.h
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 7d7c3ad1e1768d..c79bc267c7efe7 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -1032,6 +1032,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.llroundf16
libc.src.math.log10f16
libc.src.math.log10p1f16
+ libc.src.math.log1pf16
libc.src.math.log2f16
libc.src.math.log2p1f16
libc.src.math.logbf16
diff --git a/libc/src/__support/math/log1pf16.h b/libc/src/__support/math/log1pf16.h
new file mode 100644
index 00000000000000..14b1a227a2aae9
--- /dev/null
+++ b/libc/src/__support/math/log1pf16.h
@@ -0,0 +1,141 @@
+//===-- Implementation header for log1pf16 -----------------------*- 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_SRC___SUPPORT_MATH_LOG1PF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LOG1PF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "expxf16_utils.h"
+#include "hdr/errno_macros.h"
+#include "hdr/fenv_macros.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+#include "src/__support/macros/properties/cpu_features.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE float16 log1pf16(float16 x) {
+ using namespace math::expxf16_internal;
+ using FPBits = fputil::FPBits<float16>;
+ FPBits x_bits(x);
+
+ uint16_t x_u = x_bits.uintval();
+ uint16_t x_abs = x_u & 0x7fffU;
+
+ constexpr size_t N_LOG1PF16_EXCEPTS = 6;
+ constexpr fputil::ExceptValues<float16, N_LOG1PF16_EXCEPTS>
+ LOG1PF16_EXCEPTS = {{
+ // (input, RZ output, RU offset, RD offset, RN offset)
+ // x = 0x1.f24p-7, log1pf16(x) = 0x1.ee4p-7 (RZ)
+ {0x23C9U, 0x23B9U, 1U, 0U, 1U},
+ // x = 0x1.988p0, log1pf16(x) = 0x1.e84p-1 (RZ)
+ {0x3E62U, 0x3BA1U, 1U, 0U, 1U},
+ // x = -0x1.e5p-7, log1pf16(x) = -0x1.e88p-7 (RZ)
+ {0xA394U, 0xA3A2U, 0U, 1U, 1U},
+ // x = -0x1.ed4p-7, log1pf16(x) = -0x1.f1p-7 (RZ)
+ {0xA3B5U, 0xA3C4U, 0U, 1U, 0U},
+ // x = -0x1.ae4p-6, log1pf16(x) = -0x1.b4p-6 (RZ)
+ {0xA6B9U, 0xA6D0U, 0U, 1U, 0U},
+ // x = -0x1.f6cp-6, log1pf16(x) = -0x1.fe8p-6 (RZ)
+ {0xA7DBU, 0xA7FAU, 0U, 1U, 1U},
+ }};
+
+ if (auto r = LOG1PF16_EXCEPTS.lookup(x_u); LIBC_UNLIKELY(r.has_value()))
+ return r.value();
+
+ // If x is NaN, +/-inf, or |x| <= 2^-3.
+ if (LIBC_UNLIKELY(x_abs <= 0x3000U || x_abs >= 0x7c00U)) {
+ if (x_bits.is_nan()) {
+ if (x_bits.is_signaling_nan()) {
+ fputil::raise_except_if_required(FE_INVALID);
+ return FPBits::quiet_nan().get_val();
+ }
+ return x;
+ }
+
+ if (x_abs <= 0x3000U) {
+ // log1p(+/-0) = +/-0
+ if (x_abs == 0U)
+ return x;
+
+ // Degree-5 minimax polynomial generated by Sollya with:
+ // > display = hexadecimal;
+ // > P = fpminimax(log(1 + x)/x, [|0, 1, 2, 3, 4|], [|SG...|],
+ // [-2^-3, 2^-3]);
+ // > x * P;
+ // > dirtyinfnorm((log(1 + x) - x*P) / log(1 + x), [-2^-3, 2^-3]);
+ // 0x1.65afe505af70502b729765651fe9ef9d2071f0f89p-22
+ float xf = x;
+ return fputil::cast<float16>(
+ xf * fputil::polyeval(xf, 0x1p+0f, -0x1.fffc9cp-2f, 0x1.555174p-2f,
+ -0x1.03601ap-2f, 0x1.9ff8eep-3f));
+ }
+
+ if (x_u == 0x7c00U)
+ return FPBits::inf().get_val();
+
+ fputil::set_errno_if_required(EDOM);
+ fputil::raise_except_if_required(FE_INVALID);
+ return FPBits::quiet_nan().get_val();
+ }
+
+ // log1p(-1) = -inf
+ if (LIBC_UNLIKELY(x_u == 0xbc00U)) {
+ fputil::raise_except_if_required(FE_DIVBYZERO);
+ return FPBits::inf(Sign::NEG).get_val();
+ }
+
+ // log1p(x) = NaN for x < -1
+ if (LIBC_UNLIKELY(x_u > 0xbc00U)) {
+ fputil::set_errno_if_required(EDOM);
+ fputil::raise_except_if_required(FE_INVALID);
+ return FPBits::quiet_nan().get_val();
+ }
+
+ float xf = x;
+ float y = 1.0f + xf;
+
+ using FPBitsFloat = fputil::FPBits<float>;
+ FPBitsFloat y_bits(y);
+
+ if (LIBC_UNLIKELY(y_bits.is_zero()))
+ return FPBits::inf(Sign::NEG).get_val();
+
+ int m = y_bits.get_exponent();
+ y_bits.set_biased_exponent(FPBitsFloat::EXP_BIAS);
+ float mant_f = y_bits.get_val();
+ int f = y_bits.get_mantissa() >> (FPBitsFloat::FRACTION_LEN - 5);
+
+ float v = fputil::multiply_add(mant_f, ONE_OVER_F_F[f], -1.0f);
+
+ // Reusing the same log(1+v)/v minimax poly already used in logf16.h.
+ float log1p_d_over_f =
+ v * fputil::polyeval(v, 0x1p+0f, -0x1.001804p-1f, 0x1.557ef6p-2f);
+ float log_1_mant = LOGF_F[f] + log1p_d_over_f;
+ return fputil::cast<float16>(
+ fputil::multiply_add(static_cast<float>(m), LOGF_2, log_1_mant));
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LOG1PF16_H
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 4f1dd95a6993da..721ef2188d9d53 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -406,6 +406,7 @@ add_math_entrypoint_object(log10p1f16)
add_math_entrypoint_object(log1p)
add_math_entrypoint_object(log1pf)
+add_math_entrypoint_object(log1pf16)
add_math_entrypoint_object(log2)
add_math_entrypoint_object(log2f)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 13cb65ff37e0b5..19d23d0818576d 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1799,6 +1799,17 @@ add_entrypoint_object(
libc.src.errno.errno
)
+add_entrypoint_object(
+ log1pf16
+ SRCS
+ log1pf16.cpp
+ HDRS
+ ../log1pf16.h
+ DEPENDS
+ libc.src.__support.math.log1pf16
+ libc.src.errno.errno
+)
+
add_entrypoint_object(
log2p1f16
SRCS
diff --git a/libc/src/math/generic/log1pf16.cpp b/libc/src/math/generic/log1pf16.cpp
new file mode 100644
index 00000000000000..123426202d7dd6
--- /dev/null
+++ b/libc/src/math/generic/log1pf16.cpp
@@ -0,0 +1,18 @@
+//===-- Half-precision log(1+x) function ---------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/log1pf16.h"
+#include "src/__support/math/log1pf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float16, log1pf16, (float16 x)) {
+ return math::log1pf16(x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/log1pf16.h b/libc/src/math/log1pf16.h
new file mode 100644
index 00000000000000..2fdfe19bf7da98
--- /dev/null
+++ b/libc/src/math/log1pf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for log1pf16 -----------------------*- 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_SRC_MATH_LOG1PF16_H
+#define LLVM_LIBC_SRC_MATH_LOG1PF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float16 log1pf16(float16 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_LOG1PF16_H
>From 1d84c9ecec07097bc4be2d3b1e2087cb3da13a02 Mon Sep 17 00:00:00 2001
From: usefahmed07 <youssef.ahmed.hamaza at gmail.com>
Date: Fri, 18 Sep 2026 11:54:26 +0300
Subject: [PATCH 2/9] [libc][math] Complete registration checklist for log1pf16
Adds math.yaml entry, entrypoints across all supported platforms
(gpu/amdgpu, gpu/nvptx, baremetal/riscv, baremetal/aarch64,
freebsd/x86_64, darwin/aarch64, linux/riscv, linux/aarch64), and
shared math library support (shared/math.h, shared/math/log1pf16.h,
shared_math_test.cpp) per the add_math_function.md checklist.
Assisted-by: Claude (Anthropic)
---
libc/config/baremetal/aarch64/entrypoints.txt | 1 +
libc/config/baremetal/riscv/entrypoints.txt | 1 +
libc/config/darwin/aarch64/entrypoints.txt | 1 +
libc/config/freebsd/x86_64/entrypoints.txt | 1 +
libc/config/gpu/amdgpu/entrypoints.txt | 1 +
libc/config/gpu/nvptx/entrypoints.txt | 1 +
libc/config/linux/aarch64/entrypoints.txt | 1 +
libc/config/linux/riscv/entrypoints.txt | 1 +
libc/include/math.yaml | 7 +++
libc/shared/math.h | 1 +
libc/shared/math/log1pf16.h | 29 +++++++++++
libc/src/__support/math/CMakeLists.txt | 18 +++++++
libc/test/shared/CMakeLists.txt | 1 +
libc/test/shared/shared_math_test.cpp | 1 +
libc/test/src/math/CMakeLists.txt | 11 +++++
libc/test/src/math/log1pf16_test.cpp | 49 +++++++++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 13 +++++
libc/test/src/math/smoke/log1pf16_test.cpp | 48 ++++++++++++++++++
.../llvm-project-overlay/libc/BUILD.bazel | 28 +++++++++++
.../libc/test/src/math/BUILD.bazel | 2 +
20 files changed, 216 insertions(+)
create mode 100644 libc/shared/math/log1pf16.h
create mode 100644 libc/test/src/math/log1pf16_test.cpp
create mode 100644 libc/test/src/math/smoke/log1pf16_test.cpp
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 7ec212d8709692..34ca7b6fb21678 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -704,6 +704,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.log10f16
libc.src.math.log10p1f16
libc.src.math.log2f16
+ libc.src.math.log1pf16
libc.src.math.log2p1f16
libc.src.math.logbf16
libc.src.math.logf16
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index b847a2bb1f47f0..59a61fea3d1321 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -707,6 +707,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.log10f16
libc.src.math.log10p1f16
libc.src.math.log2f16
+ libc.src.math.log1pf16
libc.src.math.log2p1f16
libc.src.math.logbf16
libc.src.math.logf16
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 5600b82ad3410b..c7e77afe7b48bb 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -526,6 +526,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.log10f16
libc.src.math.log10p1f16
libc.src.math.log2f16
+ libc.src.math.log1pf16
libc.src.math.log2p1f16
libc.src.math.logbf16
libc.src.math.logf16
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 8f6c178301c2f2..60ce0a98e6f05c 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -468,6 +468,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.log10f16
libc.src.math.log10p1f16
libc.src.math.log2f16
+ libc.src.math.log1pf16
libc.src.math.log2p1f16
libc.src.math.logbf16
libc.src.math.logf16
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 2eaef608e9a7ac..2584ddc297ae6e 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -640,6 +640,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.log10f16
libc.src.math.log10p1f16
libc.src.math.log2f16
+ libc.src.math.log1pf16
libc.src.math.log2p1f16
libc.src.math.logbf16
libc.src.math.logf16
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 79d0c733ec3c01..3cbcd81bae1b47 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -638,6 +638,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.log10f16
libc.src.math.log10p1f16
libc.src.math.log2f16
+ libc.src.math.log1pf16
libc.src.math.log2p1f16
libc.src.math.logbf16
libc.src.math.logf16
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index be4d80db3afb37..a8fcfecc47ba6e 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -937,6 +937,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.llrintf16
libc.src.math.llroundf16
libc.src.math.log10p1f16
+ libc.src.math.log1pf16
libc.src.math.log2p1f16
libc.src.math.logbf16
libc.src.math.lrintf16
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 20e33295bfb206..b06ed6cc21ac67 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -1011,6 +1011,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.log10f16
libc.src.math.log10p1f16
libc.src.math.log2f16
+ libc.src.math.log1pf16
libc.src.math.log2p1f16
libc.src.math.logbf16
libc.src.math.logf16
diff --git a/libc/include/math.yaml b/libc/include/math.yaml
index 006233e579f86c..84ef73c323819e 100644
--- a/libc/include/math.yaml
+++ b/libc/include/math.yaml
@@ -1868,6 +1868,13 @@ functions:
arguments:
- type: _Float16
guard: LIBC_TYPES_HAS_FLOAT16
+ - name: log1pf16
+ standards:
+ - stdc
+ return_type: _Float16
+ arguments:
+ - type: _Float16
+ guard: LIBC_TYPES_HAS_FLOAT16
- name: log2p1f16
standards:
- stdc
diff --git a/libc/shared/math.h b/libc/shared/math.h
index eb72bebcb53bfa..f3d9be7c6a0231 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -338,6 +338,7 @@
#include "math/log10p1f16.h"
#include "math/log1p.h"
#include "math/log1pf.h"
+#include "math/log1pf16.h"
#include "math/log2.h"
#include "math/log2f.h"
#include "math/log2f16.h"
diff --git a/libc/shared/math/log1pf16.h b/libc/shared/math/log1pf16.h
new file mode 100644
index 00000000000000..5622b03eba3669
--- /dev/null
+++ b/libc/shared/math/log1pf16.h
@@ -0,0 +1,29 @@
+//===-- Shared log1pf16 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_LOG1PF16_H
+#define LLVM_LIBC_SHARED_MATH_LOG1PF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/log1pf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::log1pf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_LOG1PF16_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 03dd7c1970bf8d..bb44aafbc8c4a1 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -5329,6 +5329,24 @@ add_header_library(
libc.src.__support.macros.properties.cpu_features
)
+add_header_library(
+ log1pf16
+ HDRS
+ log1pf16.h
+ DEPENDS
+ .expxf16_utils
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.cast
+ libc.src.__support.FPUtil.except_value_utils
+ libc.src.__support.FPUtil.fenv_impl
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.multiply_add
+ libc.src.__support.FPUtil.polyeval
+ libc.src.__support.macros.optimization
+ libc.src.__support.macros.properties.cpu_features
+)
+
add_header_library(
log2p1f16
HDRS
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 8c5d623d60ce30..3dae9a39e4bafd 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -335,6 +335,7 @@ else()
libc.src.__support.math.log10f
libc.src.__support.math.log1p
libc.src.__support.math.log1pf
+ libc.src.__support.math.log1pf16
libc.src.__support.math.log2
libc.src.__support.math.logb
libc.src.__support.math.log2f
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index d0581b5dababa9..e8d3bbf0ac65e6 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -62,6 +62,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
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(0.0f16, LIBC_NAMESPACE::shared::log1pf16(0.0f16));
EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::log2p1f16(1.0f16));
EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::logbf16(1.0f16));
EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::lgammaf16(1.0f16));
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index d88afe6370e27b..99b32030783966 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2487,6 +2487,17 @@ add_fp_unittest(
libc.src.math.log10p1f16
)
+add_fp_unittest(
+ log1pf16_test
+ NEED_MPFR
+ SUITE
+ libc-math-unittests
+ SRCS
+ log1pf16_test.cpp
+ DEPENDS
+ libc.src.math.log1pf16
+)
+
add_fp_unittest(
log2p1f16_test
NEED_MPFR
diff --git a/libc/test/src/math/log1pf16_test.cpp b/libc/test/src/math/log1pf16_test.cpp
new file mode 100644
index 00000000000000..e671aa670fece5
--- /dev/null
+++ b/libc/test/src/math/log1pf16_test.cpp
@@ -0,0 +1,49 @@
+//===-- Exhaustive test for log1pf16 --------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/macros/optimization.h"
+#include "src/math/log1pf16.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+#include "utils/MPFRWrapper/MPFRUtils.h"
+
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
+using LlvmLibcLog1pf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
+
+namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
+
+// Range: [0, Inf];
+static constexpr uint16_t POS_START = 0x0000U;
+static constexpr uint16_t POS_STOP = 0x7c00U;
+
+// Range: [-1, 0];
+static constexpr uint16_t NEG_START = 0x8000U;
+static constexpr uint16_t NEG_STOP = 0xbc00U;
+
+TEST_F(LlvmLibcLog1pf16Test, PositiveRange) {
+ for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
+ float16 x = FPBits(v).get_val();
+ EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x,
+ LIBC_NAMESPACE::log1pf16(x),
+ TOLERANCE + 0.5);
+ }
+}
+
+TEST_F(LlvmLibcLog1pf16Test, NegativeRange) {
+ for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
+ float16 x = FPBits(v).get_val();
+ EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x,
+ LIBC_NAMESPACE::log1pf16(x),
+ TOLERANCE + 0.5);
+ }
+}
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 76caeef863e342..8eb59eedf81172 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4599,6 +4599,19 @@ add_fp_unittest(
libc.src.__support.FPUtil.cast
)
+add_fp_unittest(
+ log1pf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ log1pf16_test.cpp
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.math.log1pf16
+ libc.src.__support.FPUtil.cast
+)
+
add_fp_unittest(
log2p1f16_test
SUITE
diff --git a/libc/test/src/math/smoke/log1pf16_test.cpp b/libc/test/src/math/smoke/log1pf16_test.cpp
new file mode 100644
index 00000000000000..da0a0653981f29
--- /dev/null
+++ b/libc/test/src/math/smoke/log1pf16_test.cpp
@@ -0,0 +1,48 @@
+//===-- Unittests for log1pf16 --------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "hdr/errno_macros.h"
+#include "hdr/fenv_macros.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/math/log1pf16.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+using LlvmLibcLog1pf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
+
+TEST_F(LlvmLibcLog1pf16Test, SpecialNumbers) {
+ EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::log1pf16(aNaN));
+ EXPECT_MATH_ERRNO(0);
+
+ EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::log1pf16(sNaN),
+ FE_INVALID);
+ EXPECT_MATH_ERRNO(0);
+
+ EXPECT_FP_EQ_ALL_ROUNDING(inf, LIBC_NAMESPACE::log1pf16(inf));
+ EXPECT_MATH_ERRNO(0);
+
+ EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::log1pf16(neg_inf));
+ EXPECT_MATH_ERRNO(EDOM);
+
+ EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::log1pf16(zero));
+ EXPECT_MATH_ERRNO(0);
+
+ EXPECT_FP_EQ_ALL_ROUNDING(neg_zero, LIBC_NAMESPACE::log1pf16(neg_zero));
+ EXPECT_MATH_ERRNO(0);
+
+ EXPECT_FP_EQ_WITH_EXCEPTION_ALL_ROUNDING(
+ neg_inf,
+ LIBC_NAMESPACE::log1pf16(LIBC_NAMESPACE::fputil::cast<float16>(-1.0)),
+ FE_DIVBYZERO);
+ EXPECT_MATH_ERRNO(0);
+
+ EXPECT_FP_EQ_ALL_ROUNDING(
+ aNaN,
+ LIBC_NAMESPACE::log1pf16(LIBC_NAMESPACE::fputil::cast<float16>(-2.0)));
+ EXPECT_MATH_ERRNO(EDOM);
+}
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 52b18885d90982..b02bcbd94f99fa 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -10452,6 +10452,27 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_log1pf16",
+ hdrs = ["src/__support/math/log1pf16.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_polyeval",
+ ":__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_log2p1f16",
hdrs = ["src/__support/math/log2p1f16.h"],
@@ -14507,6 +14528,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "log1pf16",
+ additional_deps = [
+ ":__support_math_log1pf16",
+ ],
+)
+
libc_math_function(
name = "log2p1f16",
additional_deps = [
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
index c39dc612851536..1df5c46a14ff4a 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
@@ -1111,6 +1111,8 @@ math_mpfr_test(name = "logf16")
math_mpfr_test(name = "log2f16")
+math_mpfr_test(name = "log1pf16")
+
math_mpfr_test(name = "log2p1f16")
math_mpfr_test(name = "log10f16")
>From e86eadb65db6b6b57da908fda60916c4f17dbd17 Mon Sep 17 00:00:00 2001
From: usefahmed07 <youssef.ahmed.hamaza at gmail.com>
Date: Sat, 19 Sep 2026 01:43:20 +0300
Subject: [PATCH 3/9] [libc][math] Apply clang-format to log1pf16
---
libc/src/__support/math/log1pf16.h | 7 ++++---
libc/src/math/generic/log1pf16.cpp | 4 +---
libc/src/math/log1pf16.h | 3 ++-
libc/test/src/math/smoke/log1pf16_test.cpp | 3 +--
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/libc/src/__support/math/log1pf16.h b/libc/src/__support/math/log1pf16.h
index 14b1a227a2aae9..07463290eff530 100644
--- a/libc/src/__support/math/log1pf16.h
+++ b/libc/src/__support/math/log1pf16.h
@@ -1,4 +1,5 @@
-//===-- Implementation header for log1pf16 -----------------------*- C++ -*-===//
+//===-- Implementation header for log1pf16 -----------------------*- C++
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -40,8 +41,8 @@ LIBC_INLINE float16 log1pf16(float16 x) {
uint16_t x_abs = x_u & 0x7fffU;
constexpr size_t N_LOG1PF16_EXCEPTS = 6;
- constexpr fputil::ExceptValues<float16, N_LOG1PF16_EXCEPTS>
- LOG1PF16_EXCEPTS = {{
+ constexpr fputil::ExceptValues<float16, N_LOG1PF16_EXCEPTS> LOG1PF16_EXCEPTS =
+ {{
// (input, RZ output, RU offset, RD offset, RN offset)
// x = 0x1.f24p-7, log1pf16(x) = 0x1.ee4p-7 (RZ)
{0x23C9U, 0x23B9U, 1U, 0U, 1U},
diff --git a/libc/src/math/generic/log1pf16.cpp b/libc/src/math/generic/log1pf16.cpp
index 123426202d7dd6..7b1cf73fa6470c 100644
--- a/libc/src/math/generic/log1pf16.cpp
+++ b/libc/src/math/generic/log1pf16.cpp
@@ -11,8 +11,6 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(float16, log1pf16, (float16 x)) {
- return math::log1pf16(x);
-}
+LLVM_LIBC_FUNCTION(float16, log1pf16, (float16 x)) { return math::log1pf16(x); }
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/log1pf16.h b/libc/src/math/log1pf16.h
index 2fdfe19bf7da98..17a04ff38bdf81 100644
--- a/libc/src/math/log1pf16.h
+++ b/libc/src/math/log1pf16.h
@@ -1,4 +1,5 @@
-//===-- Implementation header for log1pf16 -----------------------*- C++ -*-===//
+//===-- Implementation header for log1pf16 -----------------------*- C++
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/math/smoke/log1pf16_test.cpp b/libc/test/src/math/smoke/log1pf16_test.cpp
index da0a0653981f29..e53bc52a2ef36f 100644
--- a/libc/test/src/math/smoke/log1pf16_test.cpp
+++ b/libc/test/src/math/smoke/log1pf16_test.cpp
@@ -19,8 +19,7 @@ TEST_F(LlvmLibcLog1pf16Test, SpecialNumbers) {
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::log1pf16(aNaN));
EXPECT_MATH_ERRNO(0);
- EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::log1pf16(sNaN),
- FE_INVALID);
+ EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::log1pf16(sNaN), FE_INVALID);
EXPECT_MATH_ERRNO(0);
EXPECT_FP_EQ_ALL_ROUNDING(inf, LIBC_NAMESPACE::log1pf16(inf));
>From f7f8686fbcc09cbbad4052c620b414525566ed5c Mon Sep 17 00:00:00 2001
From: usefahmed07 <youssef.ahmed.hamaza at gmail.com>
Date: Mon, 21 Sep 2026 21:59:51 +0300
Subject: [PATCH 4/9] [libc][math] Add more exceptional cases for log1pf16
---
libc/src/__support/math/log1pf16.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libc/src/__support/math/log1pf16.h b/libc/src/__support/math/log1pf16.h
index 07463290eff530..1bd740acdac7f7 100644
--- a/libc/src/__support/math/log1pf16.h
+++ b/libc/src/__support/math/log1pf16.h
@@ -40,14 +40,20 @@ LIBC_INLINE float16 log1pf16(float16 x) {
uint16_t x_u = x_bits.uintval();
uint16_t x_abs = x_u & 0x7fffU;
- constexpr size_t N_LOG1PF16_EXCEPTS = 6;
+ constexpr size_t N_LOG1PF16_EXCEPTS = 9;
constexpr fputil::ExceptValues<float16, N_LOG1PF16_EXCEPTS> LOG1PF16_EXCEPTS =
{{
// (input, RZ output, RU offset, RD offset, RN offset)
// x = 0x1.f24p-7, log1pf16(x) = 0x1.ee4p-7 (RZ)
{0x23C9U, 0x23B9U, 1U, 0U, 1U},
+ // x = 0x1.6ccp-2, log1pf16(x) = 0x1.38p-2 (RZ)
+ {0x35B3U, 0x34E0U, 1U, 0U, 0U},
// x = 0x1.988p0, log1pf16(x) = 0x1.e84p-1 (RZ)
{0x3E62U, 0x3BA1U, 1U, 0U, 1U},
+ // x = 0x1.35p2, log1pf16(x) = 0x1.c34p0 (RZ)
+ {0x44D4U, 0x3F0DU, 1U, 0U, 0U},
+ // x = 0x1.d48p9, log1pf16(x) = 0x1.b5cp2 (RZ)
+ {0x6352U, 0x46D7U, 1U, 0U, 1U},
// x = -0x1.e5p-7, log1pf16(x) = -0x1.e88p-7 (RZ)
{0xA394U, 0xA3A2U, 0U, 1U, 1U},
// x = -0x1.ed4p-7, log1pf16(x) = -0x1.f1p-7 (RZ)
>From 901f024a4d614e91d405f0974498bac4fb03d73d Mon Sep 17 00:00:00 2001
From: usefahmed07 <youssef.ahmed.hamaza at gmail.com>
Date: Mon, 21 Sep 2026 22:01:50 +0300
Subject: [PATCH 5/9] [libc][math] Add more exceptional cases for log1pf16
---
libc/src/__support/math/log1pf16.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libc/src/__support/math/log1pf16.h b/libc/src/__support/math/log1pf16.h
index 1bd740acdac7f7..3e5cb636fcd436 100644
--- a/libc/src/__support/math/log1pf16.h
+++ b/libc/src/__support/math/log1pf16.h
@@ -40,12 +40,16 @@ LIBC_INLINE float16 log1pf16(float16 x) {
uint16_t x_u = x_bits.uintval();
uint16_t x_abs = x_u & 0x7fffU;
- constexpr size_t N_LOG1PF16_EXCEPTS = 9;
+ constexpr size_t N_LOG1PF16_EXCEPTS = 11;
constexpr fputil::ExceptValues<float16, N_LOG1PF16_EXCEPTS> LOG1PF16_EXCEPTS =
{{
// (input, RZ output, RU offset, RD offset, RN offset)
// x = 0x1.f24p-7, log1pf16(x) = 0x1.ee4p-7 (RZ)
{0x23C9U, 0x23B9U, 1U, 0U, 1U},
+ // x = 0x1.04cp-3, log1pf16(x) = 0x1.eacp-4 (RZ)
+ {0x3013U, 0x2FABU, 1U, 0U, 1U},
+ // x = 0x1.6c4p-3, log1pf16(x) = 0x1.4fp-3 (RZ)
+ {0x31B1U, 0x313CU, 1U, 0U, 1U},
// x = 0x1.6ccp-2, log1pf16(x) = 0x1.38p-2 (RZ)
{0x35B3U, 0x34E0U, 1U, 0U, 0U},
// x = 0x1.988p0, log1pf16(x) = 0x1.e84p-1 (RZ)
>From d865036174740bae5a99bb51e977a5b33fb2ece8 Mon Sep 17 00:00:00 2001
From: usefahmed07 <youssef.ahmed.hamaza at gmail.com>
Date: Fri, 25 Sep 2026 18:15:08 +0300
Subject: [PATCH 6/9] Address review comments: fix header comment, include
path, guard ExceptValues with LIBC_MATH_HAS_SKIP_ACCURATE_PASS
---
libc/src/__support/math/log1pf16.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libc/src/__support/math/log1pf16.h b/libc/src/__support/math/log1pf16.h
index 3e5cb636fcd436..23af31e1cd995f 100644
--- a/libc/src/__support/math/log1pf16.h
+++ b/libc/src/__support/math/log1pf16.h
@@ -1,5 +1,4 @@
-//===-- Implementation header for log1pf16 -----------------------*- C++
-//-*-===//
+//===-- Implementation header for log1pf16 ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,7 +13,6 @@
#ifdef LIBC_TYPES_HAS_FLOAT16
-#include "expxf16_utils.h"
#include "hdr/errno_macros.h"
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/FEnvImpl.h"
@@ -27,6 +25,7 @@
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/math/expxf16_utils.h"
namespace LIBC_NAMESPACE_DECL {
@@ -40,6 +39,7 @@ LIBC_INLINE float16 log1pf16(float16 x) {
uint16_t x_u = x_bits.uintval();
uint16_t x_abs = x_u & 0x7fffU;
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr size_t N_LOG1PF16_EXCEPTS = 11;
constexpr fputil::ExceptValues<float16, N_LOG1PF16_EXCEPTS> LOG1PF16_EXCEPTS =
{{
@@ -70,6 +70,7 @@ LIBC_INLINE float16 log1pf16(float16 x) {
if (auto r = LOG1PF16_EXCEPTS.lookup(x_u); LIBC_UNLIKELY(r.has_value()))
return r.value();
+#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// If x is NaN, +/-inf, or |x| <= 2^-3.
if (LIBC_UNLIKELY(x_abs <= 0x3000U || x_abs >= 0x7c00U)) {
>From 7483923a6e77af59be220867b2bb3c77b10c1d74 Mon Sep 17 00:00:00 2001
From: usefahmed07 <youssef.ahmed.hamaza at gmail.com>
Date: Fri, 23 Oct 2026 11:42:29 +0300
Subject: [PATCH 7/9] [libc][math] Fix test suite name for log1pf16
---
libc/test/src/math/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 99b32030783966..055400ce385ba3 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2491,7 +2491,7 @@ add_fp_unittest(
log1pf16_test
NEED_MPFR
SUITE
- libc-math-unittests
+ libc-math-tests
SRCS
log1pf16_test.cpp
DEPENDS
>From 608c8ec86154d4507596d840c4f994b178be23cf Mon Sep 17 00:00:00 2001
From: usefahmed07 <youssef.ahmed.hamaza at gmail.com>
Date: Fri, 23 Oct 2026 20:39:32 +0300
Subject: [PATCH 8/9] [libc][math] Update log1pf16 file headers to the new LLVM
style
---
libc/shared/math/log1pf16.h | 2 +-
libc/src/__support/math/log1pf16.h | 2 +-
libc/src/math/generic/log1pf16.cpp | 2 +-
libc/src/math/log1pf16.h | 3 +--
libc/test/src/math/log1pf16_test.cpp | 2 +-
libc/test/src/math/smoke/log1pf16_test.cpp | 2 +-
6 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/libc/shared/math/log1pf16.h b/libc/shared/math/log1pf16.h
index 5622b03eba3669..e9fd5d6c10755b 100644
--- a/libc/shared/math/log1pf16.h
+++ b/libc/shared/math/log1pf16.h
@@ -1,4 +1,4 @@
-//===-- Shared log1pf16 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.
diff --git a/libc/src/__support/math/log1pf16.h b/libc/src/__support/math/log1pf16.h
index 23af31e1cd995f..9d23974ea0e309 100644
--- a/libc/src/__support/math/log1pf16.h
+++ b/libc/src/__support/math/log1pf16.h
@@ -1,4 +1,4 @@
-//===-- Implementation header for log1pf16 ----------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/math/generic/log1pf16.cpp b/libc/src/math/generic/log1pf16.cpp
index 7b1cf73fa6470c..5e7388cbd5300d 100644
--- a/libc/src/math/generic/log1pf16.cpp
+++ b/libc/src/math/generic/log1pf16.cpp
@@ -1,4 +1,4 @@
-//===-- Half-precision log(1+x) function ---------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/math/log1pf16.h b/libc/src/math/log1pf16.h
index 17a04ff38bdf81..695eaf73035781 100644
--- a/libc/src/math/log1pf16.h
+++ b/libc/src/math/log1pf16.h
@@ -1,5 +1,4 @@
-//===-- Implementation header for log1pf16 -----------------------*- C++
-//-*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/math/log1pf16_test.cpp b/libc/test/src/math/log1pf16_test.cpp
index e671aa670fece5..8e6778227135c8 100644
--- a/libc/test/src/math/log1pf16_test.cpp
+++ b/libc/test/src/math/log1pf16_test.cpp
@@ -1,4 +1,4 @@
-//===-- Exhaustive test for log1pf16 --------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/math/smoke/log1pf16_test.cpp b/libc/test/src/math/smoke/log1pf16_test.cpp
index e53bc52a2ef36f..7eb09e12b6ba9c 100644
--- a/libc/test/src/math/smoke/log1pf16_test.cpp
+++ b/libc/test/src/math/smoke/log1pf16_test.cpp
@@ -1,4 +1,4 @@
-//===-- Unittests for log1pf16 --------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
>From b57e2d09545d4b975d3adbc7f2c3aaf753b3ee9d Mon Sep 17 00:00:00 2001
From: usefahmed07 <youssef.ahmed.hamaza at gmail.com>
Date: Fri, 23 Oct 2026 21:48:00 +0300
Subject: [PATCH 9/9] [libc][math] Address review comments on log1pf16
Drop the unused cpu_features.h include, remove the redundant math::
qualifier in the using-directive, and add the smoke test to bazel.
---
libc/src/__support/math/log1pf16.h | 3 +--
.../llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel | 1 +
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libc/src/__support/math/log1pf16.h b/libc/src/__support/math/log1pf16.h
index 9d23974ea0e309..745d745b36a942 100644
--- a/libc/src/__support/math/log1pf16.h
+++ b/libc/src/__support/math/log1pf16.h
@@ -24,7 +24,6 @@
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
-#include "src/__support/macros/properties/cpu_features.h"
#include "src/__support/math/expxf16_utils.h"
namespace LIBC_NAMESPACE_DECL {
@@ -32,7 +31,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
LIBC_INLINE float16 log1pf16(float16 x) {
- using namespace math::expxf16_internal;
+ using namespace expxf16_internal;
using FPBits = fputil::FPBits<float16>;
FPBits x_bits(x);
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index 238b2852e4cc6c..6e9e9c4cf9abcd 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -2390,6 +2390,7 @@ math_test(name = "log2f16")
math_test(name = "log2p1f16")
+math_test(name = "log1pf16")
math_test(name = "log10p1f16")
math_test(name = "logf16")
More information about the libc-commits
mailing list