← Back to Pull requests

[libc][math] Implement log1pf16 (C23) #224152

Open
usefahmed07 opened this pull request with 450 lines diff across 28 files
View on GitHub
usefahmed07 usefahmed07 commented on Sep 16, 2026 22:35 UTC
Author

Implements the C23 log1pf16 (log(1+x) for _Float16) math function.

  • Small-range (|x| <= 2^-3): degree-5 minimax polynomial generated with Sollya, following the same structure as the existing log2p1f16 implementation.

  • General range: table-based range reduction reusing logf16's existing LOGF_F / ONE_OVER_F_F lookup tables (log(1+x) = log(f) + log(1+d/f)).

  • Added an ExceptValues table for the hard-to-round cases found via the MPFR exhaustive test.

  • Registered the function across math.yaml, all supported entrypoints.txt platforms, CMakeLists (support/math, math, generic, smoke tests, MPFR tests), the shared math library, and the Bazel BUILD files.

  • Smoke test, MPFR exhaustive test (full float16 range), and shared math test all pass.
  • Assisted-by: Claude (Anthropic), human reviewed.

    Close #189543

    Diff: 450 lines (+450 / -0) across 28 files Reviewer: hulxv Review duration: 107886m
    All Vouch review confidence checks passed
    Residual risk 0.10 = Change Risk (0.80) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.80 · 450 lines diff across 28 files
    0.80
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.85 · 5 substantive comment(s)
    0.85
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    86%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.366
    Mass File Touch mass_file_touch
    0.080
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    40 items
    github-actions[bot] github-actions[bot] commented on Sep 16, 2026 22:35 UTC
    Bot

    <!--LLVM NEW CONTRIBUTOR COMMENT-->

    Hello @usefahmed07 :wave:

    Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.

    All contributions to LLVM must follow our LLVM AI Tool Use Policy. In particular, if you used AI while working on this PR, remember to add a note to the PR description.
    The LLVM Code-Review Policy and Practices document contains practical information about the PR process, including how patches are reviewed and accepted, and who can review a PR.

  • Our LLVM Developer Policy describes our expectations for code quality, commit summaries and contains notes on our CI system.
  • Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description.

    ---

    Frequently asked questions

    How do I add reviewers?

    This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically.

    You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using @ followed by their GitHub username.

    What if there are no comments?

    If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers.

    Are any special GitHub settings required to contribute to LLVM?

    We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details.

    ---

    If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse.

    Thank you,
    The LLVM Community

    llvmorg-github-actions[bot] llvmorg-github-actions[bot] commented on Sep 16, 2026 22:36 UTC
    Bot

    <!--LLVM PR SUMMARY COMMENT-->
    @llvm/pr-subscribers-backend-amdgpu

    @llvm/pr-subscribers-libc

    Author: Youssef Ahmed (usefahmed07)

    <details>
    <summary>Changes</summary>

    Implements log1pf16 (C23) per #<!-- -->189543 — small-range minimax polynomial, general-range reduction reusing the logf16 pattern, plus an ExceptValues table for 6 hard-to-round cases found via the MPFR exhaustive test. Exhaustive and smoke tests both pass.

    Fixes #<!-- -->189543

    ---
    Full diff: https://github.com/llvm/llvm-project/pull/224152.diff

    6 Files Affected:

  • (modified) libc/config/linux/x86_64/entrypoints.txt (+1)

  • (added) libc/src/__support/math/log1pf16.h (+141)

  • (modified) libc/src/math/CMakeLists.txt (+1)

  • (modified) libc/src/math/generic/CMakeLists.txt (+11)

  • (added) libc/src/math/generic/log1pf16.cpp (+18)

  • (added) libc/src/math/log1pf16.h (+21)
  • ``````

    diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
    index 3f4e563e54359..81b4ba218458f 100644
    --- a/libc/config/linux/x86_64/entrypoints.txt
    +++ b/libc/config/linux/x86_64/entrypoints.txt
    @@ -977,6 +977,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 0000000000000..14b1a227a2aae
    --- /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 2c7568f0b6361..1cbcc282f6948 100644
    --- a/libc/src/math/CMakeLists.txt
    +++ b/libc/src/math/CMakeLists.txt
    @@ -405,6 +405,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 28b8e954530dd..03a6106959b81 100644
    --- a/libc/src/math/generic/CMakeLists.txt
    +++ b/libc/src/math/generic/CMakeLists.txt
    @@ -1791,6 +1791,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 0000000000000..123426202d7dd
    --- /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 0000000000000..2fdfe19bf7da9
    --- /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
    
    
    ``````

    </details>

    usefahmed07 usefahmed07 commented on Sep 16, 2026 22:40 UTC
    Author

    Hi @Sukumarsawant, saw you were fine with someone else picking this up, so I gave it a go here. Tests are passing, would love a review whenever you're free!

    usefahmed07 usefahmed07 commented on Sep 18, 2026 08:57 UTC
    Author

    Thanks @Sukumarsawant! Went through the checklist and added the missing
    pieces: math.yaml entry, entrypoints on the other platforms, and shared
    math library wiring. Tests are passing. Let me know if anything else
    is needed!

    Sukumarsawant Sukumarsawant commented on Sep 18, 2026 09:03 UTC
    Contributor

    Please edit the title of the PR, also have you used AI in this ( please read https://llvm.org/docs/AIToolPolicy.html)

    usefahmed07 usefahmed07 commented on Sep 18, 2026 09:12 UTC
    Author

    Please edit the title of the PR, also have you used AI in this ( please read https://llvm.org/docs/AIToolPolicy.html)

    Yup, I used Claude for part of this. I reviewed
    and tested everything myself. Added an Assisted-by note and updated
    the title.

    hulxv hulxv requested changes on Sep 18, 2026 22:28 UTC
    Changes Requested Reviewer

    The title doesn't match what is done in this pr. Please change it. Also, link it to https://github.com/llvm/llvm-project/issues/189543 and close it
    at the end of pr description, add:
    Close #189543

    github-actions[bot] github-actions[bot] commented on Sep 18, 2026 22:31 UTC
    Bot

    <!--LLVM CODE FORMAT COMMENT: {clang-format}-->

    :white_check_mark: With the latest revision this PR passed the C/C++ code formatter.

    usefahmed07 usefahmed07 commented on Sep 18, 2026 22:39 UTC
    Author

    The title doesn't match what is done in this pr. Please change it. Also, link it to #189543 and close it at the end of pr description, add: Close #189543

    Done updated both. Let me know if you'd like any changes.

    lntue lntue commented on Sep 21, 2026 17:11 UTC
    Contributor

    The accuracy tests are failing. You can take a look at the logs.

    usefahmed07 usefahmed07 commented on Sep 21, 2026 19:06 UTC
    Author

    The accuracy tests are failing. You can take a look at the logs.

    Done

    lntue lntue commented on code on Sep 25, 2026 14:40 UTC
    Code Review
    libc/shared/math/log1pf16.h:1
    @@ -0,0 +1,29 @@
    +//===-- Shared log1pf16 function -------------------------------*- C++ -*-===//

    Can you update the header comments to match the new LLVM style?

    lntue lntue commented on code on Sep 25, 2026 14:40 UTC
    Code Review
    libc/src/__support/math/log1pf16.h:1
    @@ -0,0 +1,152 @@
    +//===-- Implementation header for log1pf16 -----------------------*- C++

    Can you update the header comments to match the new LLVM style?

    lntue lntue commented on code on Sep 25, 2026 14:40 UTC
    Code Review
    libc/src/__support/math/log1pf16.h:1
    @@ -0,0 +1,152 @@
    +//===-- 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"

    Use include path relative to libc/ folder.

    lntue lntue commented on code on Sep 25, 2026 14:42 UTC
    Code Review
    libc/src/__support/math/log1pf16.h:1
    @@ -0,0 +1,152 @@
    +//===-- 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 = 11;
    +  constexpr fputil::ExceptValues<float16, N_LOG1PF16_EXCEPTS> LOG1PF16_EXCEPTS =

    exclude exceptional checking when LIBC_MATH_HAS_SKIP_ACCURATE_PATH defined (check the exact spelling inside optimization.h)

    usefahmed07 usefahmed07 commented on code on Sep 25, 2026 15:16 UTC
    Code Review
    libc/src/__support/math/log1pf16.h:1
    @@ -0,0 +1,152 @@
    +//===-- Implementation header for log1pf16 -----------------------*- C++

    D

    usefahmed07 usefahmed07 commented on code on Sep 25, 2026 15:16 UTC
    Code Review
    libc/src/__support/math/log1pf16.h:1
    @@ -0,0 +1,152 @@
    +//===-- 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"

    D

    usefahmed07 usefahmed07 commented on code on Sep 25, 2026 15:18 UTC
    Code Review
    libc/src/__support/math/log1pf16.h:1
    @@ -0,0 +1,152 @@
    +//===-- 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 = 11;
    +  constexpr fputil::ExceptValues<float16, N_LOG1PF16_EXCEPTS> LOG1PF16_EXCEPTS =

    exclude exceptional checking when LIBC_MATH_HAS_SKIP_ACCURATE_PATH defined (check the exact spelling inside optimization.h)

    Fixed, guarded it with LIBC_MATH_HAS_SKIP_ACCURATE_PASS.

    arsenm arsenm commented on Sep 25, 2026 16:03 UTC
    Contributor

    I'm confused because you have the same generated profile icon as me

    usefahmed07 usefahmed07 commented on Sep 25, 2026 16:10 UTC
    Author

    I'm confused because you have the same generated profile icon as me

    Haha yeah, we somehow got the same one 🤣 You’re making me think about changing mine again btw.

    Sukumarsawant Sukumarsawant commented on Oct 19, 2026 18:42 UTC
    Contributor

    Try to debug the CI failures.
    Apart from this some comments are marked as resolved even though they aren't yet, please have a look at it.

    hulxv hulxv requested changes on Oct 22, 2026 20:01 UTC
    Changes Requested Reviewer

    it seems the CI failure is not related to your changes. please rebase the branch

    usefahmed07 usefahmed07 commented on Oct 22, 2026 20:12 UTC
    Author

    it seems the CI failure is not related to your changes. please rebase the branch

    Done, Thanks!

    lntue lntue commented on Oct 23, 2026 16:43 UTC
    Contributor

    @hulxv is blocking the PR so I will leave it to him to unblock it.

    Sukumarsawant Sukumarsawant commented on code on Oct 23, 2026 17:30 UTC
    Code Review
    libc/test/src/math/smoke/log1pf16_test.cpp:1

    not blocking but the header comments aren't updated

    Sukumarsawant Sukumarsawant commented on code on Oct 23, 2026 17:32 UTC
    Code Review
    libc/shared/math/log1pf16.h:1
    @@ -0,0 +1,29 @@
    +//===-- Shared log1pf16 function -------------------------------*- C++ -*-===//

    @usefahmed07 this one's unresolved

    Sukumarsawant Sukumarsawant commented on code on Oct 23, 2026 17:33 UTC
    Code Review
    libc/src/__support/math/log1pf16.h:1
    @@ -0,0 +1,153 @@
    +//===-- 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 "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"
    +#include "src/__support/math/expxf16_utils.h"
    +
    +namespace LIBC_NAMESPACE_DECL {
    +
    +namespace math {
    +
    +LIBC_INLINE float16 log1pf16(float16 x) {
    +  using namespace math::expxf16_internal;

    seems unnecesary since we are already inside math namespace

    usefahmed07 usefahmed07 commented on Oct 23, 2026 17:42 UTC
    Author

    @Sukumarsawant , @lntue Looks Good Now!

    Sukumarsawant Sukumarsawant commented on code on Oct 23, 2026 18:09 UTC
    Code Review
    libc/src/__support/math/log1pf16.h:1
    @@ -0,0 +1,153 @@
    +//===----------------------------------------------------------------------===//
    +//
    +// 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 "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"

    is this needed ?

    Sukumarsawant Sukumarsawant commented on code on Oct 23, 2026 18:16 UTC
    Code Review
    libc/test/src/math/smoke/log1pf16_test.cpp:1

    smoke test can too be added to bazel

    Sukumarsawant Sukumarsawant commented on Oct 23, 2026 18:17 UTC
    Reviewer
    usefahmed07 usefahmed07 commented on code on Oct 23, 2026 18:49 UTC
    Code Review
    libc/src/__support/math/log1pf16.h:1
    @@ -0,0 +1,153 @@
    +//===----------------------------------------------------------------------===//
    +//
    +// 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 "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"

    Not needed, removed it.

    Sukumarsawant Sukumarsawant commented on Oct 23, 2026 18:51 UTC
    Contributor

    just a request to addresss the previous comments properly before re-requesting review
    >https://llvm.org/docs/CodingStandards.html#file-headers
    refer this

    This was in context with the headers not updated properly as said in https://github.com/llvm/llvm-project/pull/224152#discussion_r4105611143 and https://github.com/llvm/llvm-project/pull/224152#discussion_r4362412009

    usefahmed07 usefahmed07 commented on Oct 23, 2026 18:57 UTC
    Author

    just a request to addresss the previous comments properly before re-requesting review

    > > https://llvm.org/docs/CodingStandards.html#file-headers

    > refer this

    > This was in context with the headers not updated properly as said in #224152 (comment) and #224152 (comment)

    Sorry, I had only updated the first line before. Added the \file description block to all the log1pf16 file headers, matching the exp2bf16 files.

    lntue lntue commented on Nov 03, 2026 16:38 UTC
    Contributor

    > just a request to addresss the previous comments properly before re-requesting review

    > > https://llvm.org/docs/CodingStandards.html#file-headers

    > > refer this

    >

    >

    > This was in context with the headers not updated properly as said in #224152 (comment) and #224152 (comment)

    > Sorry, I had only updated the first line before. Added the \file description block to all the log1pf16 file headers, matching the exp2bf16 files.

    Can you take a look at the CI failures?

    usefahmed07 usefahmed07 commented on Nov 06, 2026 15:15 UTC
    Author

    > > just a request to addresss the previous comments properly before re-requesting review

    > > > https://llvm.org/docs/CodingStandards.html#file-headers

    > > > refer this

    > >

    > >

    > > This was in context with the headers not updated properly as said in #224152 (comment) and #224152 (comment)

    >

    >

    > Sorry, I had only updated the first line before. Added the \file description block to all the log1pf16 file headers, matching the exp2bf16 files.

    > Can you take a look at the CI failures?

    Done, Thanks!

    lntue lntue commented on Nov 14, 2026 14:19 UTC
    Contributor

    @usefahmed07 Do mind syncing the PR to resolve merge conflicts?

    usefahmed07 usefahmed07 commented on Nov 14, 2026 18:09 UTC
    Author

    @Intue Rebased onto latest main and resolved the conflicts. PTAL.

    Reviewers
    Assignees
    usefahmed07 usefahmed07
    Labels
    risk: low confidence: 86.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 80.1% (HIGH) · Higher = larger blast radius
    80.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 86.9% · Lower = rushed or shallow review
    86.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 10.5% · Safe to merge
    10.5%