[libc-commits] [libc] [libc][math][c23] Add log10p1f16 C23 math function (PR #184739)
via libc-commits
libc-commits at lists.llvm.org
Wed Mar 11 08:21:44 PDT 2026
================
@@ -0,0 +1,192 @@
+//===-- Implementation header for log10p1f16 ---------------------*- 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_LOG10P1F16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LOG10P1F16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "exp10_float16_constants.h"
+#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 log10p1f16(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;
+
+ // If x is +-0, +inf, NaN, -1, x < -1, or |x| <= 2^-3.
+ if (LIBC_UNLIKELY(x_abs == 0U || x_abs <= 0x3000U || x_u == 0x7c00U ||
+ x_u >= 0xbc00U || x_bits.is_nan())) {
----------------
lntue wrote:
simplify the check to:
`x_abs <= 0x3000 || x_abs >= 0x7c00`
https://github.com/llvm/llvm-project/pull/184739
More information about the libc-commits
mailing list