[libc-commits] [libc] [libc][math] Implement C23 half precision erfc function (PR #180930)
via libc-commits
libc-commits at lists.llvm.org
Sat Mar 21 08:34:49 PDT 2026
================
@@ -0,0 +1,199 @@
+//===-- Implementation header for erfcf16 -----------------------*- 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_ERFCF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ERFCF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE float16 erfcf16(float16 x) {
+ // Polynomials approximating erfc(|x|) on ( k/8, (k + 1)/8 ) generated by
+ // Sollya with: > P = fpminimax(erfc(x), [|0, 1, 2, 3, 4, 5, 6, 7|], [|D...|],
+ // [k/8, (k + 1)/8]);
+ // for k = 0..31.
----------------
lntue wrote:
Can you print the relative errors for these polynomials? Maybe min and max is ok, instead of all 32 of them.
https://github.com/llvm/llvm-project/pull/180930
More information about the libc-commits
mailing list