[all-commits] [llvm/llvm-project] f05a64: [libc][math] Implement half precision lgamma funct...

Anonmiraj via All-commits all-commits at lists.llvm.org
Sat Jul 18 18:30:11 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f05a649741f248e3809a6d0e7b5a8daf7bed74a8
      https://github.com/llvm/llvm-project/commit/f05a649741f248e3809a6d0e7b5a8daf7bed74a8
  Author: Anonmiraj <ezzibrahimx at gmail.com>
  Date:   2026-07-19 (Sun, 19 Jul 2026)

  Changed paths:
    M libc/config/baremetal/aarch64/entrypoints.txt
    M libc/config/baremetal/arm/entrypoints.txt
    M libc/config/baremetal/riscv/entrypoints.txt
    M libc/config/darwin/aarch64/entrypoints.txt
    M libc/config/gpu/amdgpu/entrypoints.txt
    M libc/config/gpu/nvptx/entrypoints.txt
    M libc/config/linux/aarch64/entrypoints.txt
    M libc/config/linux/riscv/entrypoints.txt
    M libc/config/linux/x86_64/entrypoints.txt
    M libc/docs/headers/math/index.rst
    M libc/include/math.yaml
    M libc/shared/math.h
    A libc/shared/math/lgammaf16.h
    M libc/src/__support/math/CMakeLists.txt
    A libc/src/__support/math/lgammaf16.h
    M libc/src/math/CMakeLists.txt
    M libc/src/math/generic/CMakeLists.txt
    A libc/src/math/generic/lgammaf16.cpp
    A libc/src/math/lgammaf16.h
    M libc/test/shared/CMakeLists.txt
    M libc/test/shared/shared_math_test.cpp
    M libc/test/src/math/CMakeLists.txt
    A libc/test/src/math/lgammaf16_test.cpp
    M libc/test/src/math/smoke/CMakeLists.txt
    A libc/test/src/math/smoke/lgammaf16_test.cpp
    M libc/utils/MPFRWrapper/MPCommon.cpp
    M libc/utils/MPFRWrapper/MPCommon.h
    M libc/utils/MPFRWrapper/MPFRUtils.cpp
    M libc/utils/MPFRWrapper/MPFRUtils.h
    M utils/bazel/llvm-project-overlay/libc/BUILD.bazel

  Log Message:
  -----------
  [libc][math] Implement half precision lgamma function (#192834)

The implementation uses three distinct paths based on $|x|$:

- Small ($|x| < 0.66$): Fits a degree-12 Chebyshev for $h(t) =
\frac{\text{lgamma}(t) + \log(t)}{t}$, recovering $\text{lgamma}(t) = t
\cdot h - \log(t)$.

- Medium ($|x| \in [0.66, 3.37]$): Fits a degree-20 Chebyshev for $g(t)
= \frac{\text{lgamma}(t)}{(t-1)(t-2)}$
- Stirling ($|x| > 3.37$): Uses $(x-0.5) \cdot \log(x) - x +
\frac{\log(2\pi)}{2}$ plus 1/2/4/8-term Bernoulli corrections by
sub-range.


Special cases: NaN, +/-Inf -> +Inf, +/-0 pole, negative integer pole,
lgamma(1) = lgamma(2) = 0 exactly, overflow for large positive x.

Exhaustive tests pass in all 4 rounding modes.

-- CORE-MATH reciprocal throughput --
Ntrial = 20 ; Min = 391.348 + 77.447 clc/call; Median-Min = 68.093
clc/call; Max = 540.055 clc/call;
-- System LIBC reciprocal throughput --
Ntrial = 20 ; Min = 377.829 + 81.686 clc/call; Median-Min = 64.851
clc/call; Max = 532.888 clc/call;



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list