[libc-commits] [libc] [llvm] [libc][math] Refactor log_bf16 to Header (PR #186618)
Muhammad Bassiouni via libc-commits
libc-commits at lists.llvm.org
Mon Mar 16 09:52:15 PDT 2026
================
@@ -0,0 +1,145 @@
+//===-- Implementation header for log_bf16 ----------------------*- 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_LOG_BF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LOG_BF16_H
+
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/cast.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 {
+
+// Generated by Sollya with the following commands:
+// > display = hexadecimal;
+// > round(log(2), SG, RN);
+LIBC_INLINE_VAR constexpr float BF16_LOGF_2 = 0x1.62e43p-1f;
+
+// Generated by Sollya with the following commands:
+// > display = hexadecimal;
+// > for i from 0 to 127 do print(round(log(1 + i * 2^-7), SG, RN));
+LIBC_INLINE_VAR constexpr float LOG_1_PLUS_M[128] = {
----------------
bassiounix wrote:
these 2 variables can be moved inside the function body without inlining them.
https://github.com/llvm/llvm-project/pull/186618
More information about the libc-commits
mailing list