[libc-commits] [libc] [llvm] [libc] Add fmax/fmin functions for float80 type (PR #236387)
via libc-commits
libc-commits at lists.llvm.org
Thu Oct 29 00:20:55 PDT 2026
https://github.com/Sukumarsawant updated https://github.com/llvm/llvm-project/pull/236387
>From 317e802a1806337c61a302e4b296ca613b7a974b Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 28 Oct 2026 17:13:26 +0530
Subject: [PATCH 1/3] initial commit
---
libc/config/baremetal/aarch64/entrypoints.txt | 2 +
libc/config/baremetal/arm/entrypoints.txt | 2 +
libc/config/baremetal/riscv/entrypoints.txt | 2 +
libc/config/darwin/aarch64/entrypoints.txt | 2 +
libc/config/darwin/x86_64/entrypoints.txt | 2 +
libc/config/freebsd/x86_64/entrypoints.txt | 2 +
libc/config/gpu/amdgpu/entrypoints.txt | 2 +
libc/config/gpu/nvptx/entrypoints.txt | 2 +
libc/config/linux/aarch64/entrypoints.txt | 2 +
libc/config/linux/arm/entrypoints.txt | 2 +
libc/config/linux/riscv/entrypoints.txt | 2 +
libc/config/linux/x86_64/entrypoints.txt | 2 +
libc/config/windows/entrypoints.txt | 2 +
libc/shared/math.h | 2 +
libc/shared/math/fmaxf80.h | 29 ++++++++++++++
libc/shared/math/fminf80.h | 29 ++++++++++++++
libc/src/__support/math/CMakeLists.txt | 20 ++++++++++
libc/src/__support/math/fmaxf80.h | 34 +++++++++++++++++
libc/src/__support/math/fminf80.h | 34 +++++++++++++++++
libc/src/math/CMakeLists.txt | 2 +
libc/src/math/fmaxf80.h | 28 ++++++++++++++
libc/src/math/fminf80.h | 28 ++++++++++++++
libc/src/math/generic/CMakeLists.txt | 22 +++++++++++
libc/src/math/generic/fmaxf80.cpp | 31 +++++++++++++++
libc/src/math/generic/fminf80.cpp | 31 +++++++++++++++
libc/test/shared/CMakeLists.txt | 3 ++
.../shared/shared_math_constexpr_test.cpp | 4 ++
libc/test/shared/shared_math_test.cpp | 4 ++
libc/test/src/math/smoke/CMakeLists.txt | 30 +++++++++++++++
libc/test/src/math/smoke/fmaxf80_test.cpp | 21 ++++++++++
libc/test/src/math/smoke/fminf80_test.cpp | 21 ++++++++++
.../llvm-project-overlay/libc/BUILD.bazel | 38 +++++++++++++++++++
.../libc/test/src/math/smoke/BUILD.bazel | 16 ++++++++
33 files changed, 453 insertions(+)
create mode 100644 libc/shared/math/fmaxf80.h
create mode 100644 libc/shared/math/fminf80.h
create mode 100644 libc/src/__support/math/fmaxf80.h
create mode 100644 libc/src/__support/math/fminf80.h
create mode 100644 libc/src/math/fmaxf80.h
create mode 100644 libc/src/math/fminf80.h
create mode 100644 libc/src/math/generic/fmaxf80.cpp
create mode 100644 libc/src/math/generic/fminf80.cpp
create mode 100644 libc/test/src/math/smoke/fmaxf80_test.cpp
create mode 100644 libc/test/src/math/smoke/fminf80_test.cpp
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 37b262dc10c4fd..1fa6271e957418 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -432,6 +432,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag
libc.src.math.fmaximum_mag_num
@@ -452,6 +453,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag
libc.src.math.fminimum_mag_num
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 243f22cfa240d5..0c289e85caba08 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -444,6 +444,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag
libc.src.math.fmaximum_mag_num
@@ -464,6 +465,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag
libc.src.math.fminimum_mag_num
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index cf1fc0116628aa..5bc37d5b3f1b60 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -435,6 +435,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag
libc.src.math.fmaximum_mag_num
@@ -455,6 +456,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag
libc.src.math.fminimum_mag_num
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index ca772ac1b911b1..60f78bc54c89bc 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -253,6 +253,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag
libc.src.math.fmaximum_mag_num
@@ -273,6 +274,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag
libc.src.math.fminimum_mag_num
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index b27753ea9e6672..ee9774a80cadd3 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -161,6 +161,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.fmax
#libc.src.math.fmaxf
#libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
#libc.src.math.fmaximum_mag_numf128
#libc.src.math.fmaximum_magf128
#libc.src.math.fmaximum_numf128
@@ -169,6 +170,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.fmin
#libc.src.math.fminf
#libc.src.math.fminf128
+ libc.src.math.fminf80
#libc.src.math.fminimum_mag_numf128
#libc.src.math.fminimum_magf128
#libc.src.math.fminimum_numf128
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 09e59fa625b93e..3090fac9aaf35f 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -182,12 +182,14 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum_mag_numf128
libc.src.math.fminimum_magf128
libc.src.math.fminl
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaxl
libc.src.math.fmaximum
libc.src.math.fmaximumf
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 5bb1190605eb78..7c55fffab20a4f 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -374,6 +374,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag_numf128
libc.src.math.fmaximum_magf128
@@ -394,6 +395,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag_numf128
libc.src.math.fminimum_magf128
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index d4bd70abb688ae..25dda32f367fcb 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -370,6 +370,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag_numf128
libc.src.math.fmaximum_magf128
@@ -390,6 +391,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag_numf128
libc.src.math.fminimum_magf128
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 6963896a9ed6d2..8c5f01d0665156 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -672,6 +672,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag
libc.src.math.fmaximum_mag_num
@@ -692,6 +693,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag
libc.src.math.fminimum_mag_num
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 3da362d8d0ccc5..5778fcd7a71ce6 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -465,6 +465,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag
libc.src.math.fmaximum_mag_num
@@ -485,6 +486,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag
libc.src.math.fminimum_mag_num
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 18c6209434a6a3..ebfeed32b6e828 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -733,6 +733,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag
libc.src.math.fmaximum_mag_num
@@ -753,6 +754,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag
libc.src.math.fminimum_mag_num
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index b2747d2dfeb929..b6ae890c9c83ef 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -755,6 +755,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag
libc.src.math.fmaximum_mag_num
@@ -775,6 +776,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag
libc.src.math.fminimum_mag_num
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 5f240a75c3691d..9b7655fcca2f0e 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -215,12 +215,14 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmin
libc.src.math.fminf
libc.src.math.fminf128
+ libc.src.math.fminf80
libc.src.math.fminimum_mag_numf128
libc.src.math.fminimum_magf128
libc.src.math.fminl
libc.src.math.fmax
libc.src.math.fmaxf
libc.src.math.fmaxf128
+ libc.src.math.fmaxf80
libc.src.math.fmaxl
libc.src.math.fmaximum
libc.src.math.fmaximumf
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 47f5508286c33e..2881c67c8558b3 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -184,6 +184,7 @@
#include "math/fmaxf.h"
#include "math/fmaxf128.h"
#include "math/fmaxf16.h"
+#include "math/fmaxf80.h"
#include "math/fmaximum.h"
#include "math/fmaximum_mag.h"
#include "math/fmaximum_mag_num.h"
@@ -214,6 +215,7 @@
#include "math/fminf.h"
#include "math/fminf128.h"
#include "math/fminf16.h"
+#include "math/fminf80.h"
#include "math/fminimum.h"
#include "math/fminimum_mag.h"
#include "math/fminimum_mag_num.h"
diff --git a/libc/shared/math/fmaxf80.h b/libc/shared/math/fmaxf80.h
new file mode 100644
index 00000000000000..70ccbe31a691ec
--- /dev/null
+++ b/libc/shared/math/fmaxf80.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Shared fmaxf80 function.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_FMAXF80_H
+#define LLVM_LIBC_SHARED_MATH_FMAXF80_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fmaxf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fmaxf80;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMAXF80_H
+
diff --git a/libc/shared/math/fminf80.h b/libc/shared/math/fminf80.h
new file mode 100644
index 00000000000000..4362a4250f0910
--- /dev/null
+++ b/libc/shared/math/fminf80.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Shared fminf80 function.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_FMINF80_H
+#define LLVM_LIBC_SHARED_MATH_FMINF80_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fminf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fminf80;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMINF80_H
+
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 2bbac300cfb582..9f87bd70e1d3ae 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1135,6 +1135,16 @@ add_header_library(
MISC_MATH_BASIC_OPS_OPT
)
+add_header_library(
+ fminf80
+ HDRS
+ fminf80.h
+ DEPENDS
+ libc.src.__support.FPUtil.float80
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
add_header_library(
fminimum
@@ -3899,6 +3909,16 @@ add_header_library(
MISC_MATH_BASIC_OPS_OPT
)
+add_header_library(
+ fmaxf80
+ HDRS
+ fmaxf80.h
+ DEPENDS
+ libc.src.__support.FPUtil.float80
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
add_header_library(
fmaxl
HDRS
diff --git a/libc/src/__support/math/fmaxf80.h b/libc/src/__support/math/fmaxf80.h
new file mode 100644
index 00000000000000..0afb533c0d30fe
--- /dev/null
+++ b/libc/src/__support/math/fmaxf80.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the fmaxf80 function.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FMAXF80_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMAXF80_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/float80.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+using LIBC_NAMESPACE::fputil::Float80;
+
+LIBC_INLINE constexpr Float80 fmaxf80(Float80 x, Float80 y) {
+ return fputil::fmax(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMAXF80_H
+
diff --git a/libc/src/__support/math/fminf80.h b/libc/src/__support/math/fminf80.h
new file mode 100644
index 00000000000000..3217228fc84bdd
--- /dev/null
+++ b/libc/src/__support/math/fminf80.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the fminf80 function.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FMINF80_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMINF80_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/float80.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+using LIBC_NAMESPACE::fputil::Float80;
+
+LIBC_INLINE constexpr Float80 fminf80(Float80 x, Float80 y) {
+ return fputil::fmin(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMINF80_H
+
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 5532932bfaf310..3fa13b0ee93b6a 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -251,6 +251,7 @@ add_math_entrypoint_object(fmaxf)
add_math_entrypoint_object(fmaxl)
add_math_entrypoint_object(fmaxf128)
add_math_entrypoint_object(fmaxf16)
+add_math_entrypoint_object(fmaxf80)
add_math_entrypoint_object(fmaxbf16)
add_math_entrypoint_object(fmin)
@@ -258,6 +259,7 @@ add_math_entrypoint_object(fminf)
add_math_entrypoint_object(fminl)
add_math_entrypoint_object(fminf128)
add_math_entrypoint_object(fminf16)
+add_math_entrypoint_object(fminf80)
add_math_entrypoint_object(fminbf16)
add_math_entrypoint_object(fmaximum)
diff --git a/libc/src/math/fmaxf80.h b/libc/src/math/fmaxf80.h
new file mode 100644
index 00000000000000..be21d27697eed3
--- /dev/null
+++ b/libc/src/math/fmaxf80.h
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Public declaration of the fmaxf80 entrypoint.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_FMAXF80_H
+#define LLVM_LIBC_SRC_MATH_FMAXF80_H
+
+#include "src/__support/FPUtil/float80.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float80 fmaxf80(float80 x, float80 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMAXF80_H
+
diff --git a/libc/src/math/fminf80.h b/libc/src/math/fminf80.h
new file mode 100644
index 00000000000000..daa8991e807c95
--- /dev/null
+++ b/libc/src/math/fminf80.h
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Public declaration of the fminf80 entrypoint.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_FMINF80_H
+#define LLVM_LIBC_SRC_MATH_FMINF80_H
+
+#include "src/__support/FPUtil/float80.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float80 fminf80(float80 x, float80 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMINF80_H
+
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index b00cf612180e3c..7a4e34ec2c3ef8 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2101,6 +2101,17 @@ add_entrypoint_object(
libc.src.__support.math.fminf16
)
+add_entrypoint_object(
+ fminf80
+ SRCS
+ fminf80.cpp
+ HDRS
+ ../fminf80.h
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.math.fminf80
+)
+
add_entrypoint_object(
fminbf16
SRCS
@@ -2162,6 +2173,17 @@ add_entrypoint_object(
libc.src.__support.math.fmaxf16
)
+add_entrypoint_object(
+ fmaxf80
+ SRCS
+ fmaxf80.cpp
+ HDRS
+ ../fmaxf80.h
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.math.fmaxf80
+)
+
add_entrypoint_object(
fmaxbf16
SRCS
diff --git a/libc/src/math/generic/fmaxf80.cpp b/libc/src/math/generic/fmaxf80.cpp
new file mode 100644
index 00000000000000..f9a2da0ebca60d
--- /dev/null
+++ b/libc/src/math/generic/fmaxf80.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the fmaxf80 function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fmaxf80.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/FPUtil/float80.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/math/fmaxf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+using LIBC_NAMESPACE::fputil::Float80;
+
+LLVM_LIBC_FUNCTION(float80, fmaxf80, (float80 x, float80 y)) {
+ return cpp::bit_cast<float80>(
+ math::fmaxf80(cpp::bit_cast<Float80>(x), cpp::bit_cast<Float80>(y)));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
+
diff --git a/libc/src/math/generic/fminf80.cpp b/libc/src/math/generic/fminf80.cpp
new file mode 100644
index 00000000000000..506cc82f5558a0
--- /dev/null
+++ b/libc/src/math/generic/fminf80.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the fminf80 function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fminf80.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/FPUtil/float80.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/math/fminf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+using LIBC_NAMESPACE::fputil::Float80;
+
+LLVM_LIBC_FUNCTION(float80, fminf80, (float80 x, float80 y)) {
+ return cpp::bit_cast<float80>(
+ math::fminf80(cpp::bit_cast<Float80>(x), cpp::bit_cast<Float80>(y)));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
+
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index af74e7bf00655d..b8f0f31d7f31cd 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -193,6 +193,7 @@ else()
libc.src.__support.math.fmaxf
libc.src.__support.math.fmaxf128
libc.src.__support.math.fmaxf16
+ libc.src.__support.math.fmaxf80
libc.src.__support.math.fmaximum
libc.src.__support.math.fmaximum_mag
libc.src.__support.math.fmaximum_mag_num
@@ -223,6 +224,7 @@ else()
libc.src.__support.math.fminf
libc.src.__support.math.fminf128
libc.src.__support.math.fminf16
+ libc.src.__support.math.fminf80
libc.src.__support.math.fminimum
libc.src.__support.math.fminimum_mag
libc.src.__support.math.fminimum_mag_num
@@ -621,6 +623,7 @@ else()
libc.src.__support.math.fminf
libc.src.__support.math.fminf128
libc.src.__support.math.fminf16
+ libc.src.__support.math.fminf80
libc.src.__support.math.fminimum
libc.src.__support.math.fminimum_mag
libc.src.__support.math.fminimum_mag_num
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index b7dd39e480ee84..b54f30708447c5 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -414,6 +414,10 @@ static_assert(Float128(1.0) ==
static_assert(Float80(0.0) ==
LIBC_NAMESPACE::shared::copysignf80(Float80(0.0), Float80(0.0)));
static_assert(Float80(1.0) == LIBC_NAMESPACE::shared::fabsf80(Float80(-1.0)));
+static_assert(Float80(0.0) ==
+ LIBC_NAMESPACE::shared::fmaxf80(Float80(0.0), Float80(0.0)));
+static_assert(Float80(0.0) ==
+ LIBC_NAMESPACE::shared::fminf80(Float80(0.0), Float80(0.0)));
static_assert(Float128(1.0) ==
LIBC_NAMESPACE::shared::fdimf128(Float128(1.0), Float128(0.0)));
static_assert(Float128(0.0) ==
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index f662c2c1af91e2..439b3b3d2c0490 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -679,6 +679,10 @@ TEST(LlvmLibcSharedMathTest, AllFloat80) {
EXPECT_FP_EQ(Float80(0.0),
LIBC_NAMESPACE::shared::copysignf80(Float80(0.0), Float80(0.0)));
EXPECT_FP_EQ(Float80(0.0), LIBC_NAMESPACE::shared::fabsf80(Float80(0.0)));
+ EXPECT_FP_EQ(Float80(0.0),
+ LIBC_NAMESPACE::shared::fmaxf80(Float80(0.0), Float80(0.0)));
+ EXPECT_FP_EQ(Float80(0.0),
+ LIBC_NAMESPACE::shared::fminf80(Float80(0.0), Float80(0.0)));
}
#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 6da23b09af1ed8..2e09e9b3b6452a 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2801,6 +2801,21 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
+add_fp_unittest(
+ fminf80_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ fminf80_test.cpp
+ HDRS
+ FMinTest.h
+ DEPENDS
+ libc.src.__support.FPUtil.float80
+ libc.src.math.fminf80
+ libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fp_bits
+)
+
add_fp_unittest(
fminbf16_test
SUITE
@@ -2887,6 +2902,21 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
+add_fp_unittest(
+ fmaxf80_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ fmaxf80_test.cpp
+ HDRS
+ FMaxTest.h
+ DEPENDS
+ libc.src.__support.FPUtil.float80
+ libc.src.math.fmaxf80
+ libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fp_bits
+)
+
add_fp_unittest(
fmaxbf16_test
SUITE
diff --git a/libc/test/src/math/smoke/fmaxf80_test.cpp b/libc/test/src/math/smoke/fmaxf80_test.cpp
new file mode 100644
index 00000000000000..b3442c71a427d7
--- /dev/null
+++ b/libc/test/src/math/smoke/fmaxf80_test.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Smoke tests for fmaxf80.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/FPUtil/float80.h"
+#include "src/math/fmaxf80.h"
+#include "test/src/math/smoke/FMaxTest.h"
+
+using LIBC_NAMESPACE::fputil::Float80;
+
+LIST_FMAX_TESTS(Fmaxf80, Float80, LIBC_NAMESPACE::fmaxf80)
+
diff --git a/libc/test/src/math/smoke/fminf80_test.cpp b/libc/test/src/math/smoke/fminf80_test.cpp
new file mode 100644
index 00000000000000..103bec4be5a715
--- /dev/null
+++ b/libc/test/src/math/smoke/fminf80_test.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Smoke tests for fminf80.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/FPUtil/float80.h"
+#include "src/math/fminf80.h"
+#include "test/src/math/smoke/FMinTest.h"
+
+using LIBC_NAMESPACE::fputil::Float80;
+
+LIST_FMIN_TESTS(Fminf80, Float80, LIBC_NAMESPACE::fminf80)
+
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index a80ecabdd563cd..eeb07d530c3551 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -7194,6 +7194,16 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_fminf80",
+ hdrs = ["src/__support/math/fminf80.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_fputil_float80",
+ ":__support_macros_config",
+ ],
+)
+
libc_support_library(
name = "__support_math_fminimum",
hdrs = ["src/__support/math/fminimum.h"],
@@ -9830,6 +9840,16 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_fmaxf80",
+ hdrs = ["src/__support/math/fmaxf80.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_fputil_float80",
+ ":__support_macros_config",
+ ],
+)
+
libc_support_library(
name = "__support_math_fmaxl",
hdrs = ["src/__support/math/fmaxl.h"],
@@ -13934,6 +13954,15 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "fmaxf80",
+ additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float80",
+ ":__support_math_fmaxf80",
+ ],
+)
+
libc_math_function(
name = "fmaxl",
additional_deps = [
@@ -14133,6 +14162,15 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "fminf80",
+ additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float80",
+ ":__support_math_fminf80",
+ ],
+)
+
libc_math_function(
name = "fminimum",
additional_deps = [
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index e71cf94dfdbe34..8567d8f6e5d72e 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -836,6 +836,14 @@ math_test(
hdrs = ["FMaxTest.h"],
)
+math_test(
+ name = "fmaxf80",
+ hdrs = ["FMaxTest.h"],
+ deps = [
+ "//libc:__support_fputil_float80",
+ ],
+)
+
math_test(
name = "fmaximum",
hdrs = ["FMaximumTest.h"],
@@ -1016,6 +1024,14 @@ math_test(
hdrs = ["FMinTest.h"],
)
+math_test(
+ name = "fminf80",
+ hdrs = ["FMinTest.h"],
+ deps = [
+ "//libc:__support_fputil_float80",
+ ],
+)
+
math_test(
name = "fminimum",
hdrs = ["FMinimumTest.h"],
>From 237612191f7d12296ae4258d0acf7775fbb3597c Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 28 Oct 2026 17:13:51 +0530
Subject: [PATCH 2/3] nits
---
libc/shared/math/fmaxf80.h | 1 -
libc/shared/math/fminf80.h | 1 -
libc/src/__support/math/fmaxf80.h | 1 -
libc/src/__support/math/fminf80.h | 1 -
libc/src/math/fmaxf80.h | 1 -
libc/src/math/fminf80.h | 1 -
libc/src/math/generic/fmaxf80.cpp | 1 -
libc/src/math/generic/fminf80.cpp | 1 -
libc/test/src/math/smoke/fmaxf80_test.cpp | 1 -
libc/test/src/math/smoke/fminf80_test.cpp | 1 -
10 files changed, 10 deletions(-)
diff --git a/libc/shared/math/fmaxf80.h b/libc/shared/math/fmaxf80.h
index 70ccbe31a691ec..dfa1622b2cb226 100644
--- a/libc/shared/math/fmaxf80.h
+++ b/libc/shared/math/fmaxf80.h
@@ -26,4 +26,3 @@ using math::fmaxf80;
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SHARED_MATH_FMAXF80_H
-
diff --git a/libc/shared/math/fminf80.h b/libc/shared/math/fminf80.h
index 4362a4250f0910..8879aab6242482 100644
--- a/libc/shared/math/fminf80.h
+++ b/libc/shared/math/fminf80.h
@@ -26,4 +26,3 @@ using math::fminf80;
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SHARED_MATH_FMINF80_H
-
diff --git a/libc/src/__support/math/fmaxf80.h b/libc/src/__support/math/fmaxf80.h
index 0afb533c0d30fe..6ce6ef95a97c39 100644
--- a/libc/src/__support/math/fmaxf80.h
+++ b/libc/src/__support/math/fmaxf80.h
@@ -31,4 +31,3 @@ LIBC_INLINE constexpr Float80 fmaxf80(Float80 x, Float80 y) {
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMAXF80_H
-
diff --git a/libc/src/__support/math/fminf80.h b/libc/src/__support/math/fminf80.h
index 3217228fc84bdd..9ab9f2368e4673 100644
--- a/libc/src/__support/math/fminf80.h
+++ b/libc/src/__support/math/fminf80.h
@@ -31,4 +31,3 @@ LIBC_INLINE constexpr Float80 fminf80(Float80 x, Float80 y) {
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMINF80_H
-
diff --git a/libc/src/math/fmaxf80.h b/libc/src/math/fmaxf80.h
index be21d27697eed3..c900e0abe4d369 100644
--- a/libc/src/math/fmaxf80.h
+++ b/libc/src/math/fmaxf80.h
@@ -25,4 +25,3 @@ float80 fmaxf80(float80 x, float80 y);
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_MATH_FMAXF80_H
-
diff --git a/libc/src/math/fminf80.h b/libc/src/math/fminf80.h
index daa8991e807c95..418f3f0b102f92 100644
--- a/libc/src/math/fminf80.h
+++ b/libc/src/math/fminf80.h
@@ -25,4 +25,3 @@ float80 fminf80(float80 x, float80 y);
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_MATH_FMINF80_H
-
diff --git a/libc/src/math/generic/fmaxf80.cpp b/libc/src/math/generic/fmaxf80.cpp
index f9a2da0ebca60d..1009945debd0b2 100644
--- a/libc/src/math/generic/fmaxf80.cpp
+++ b/libc/src/math/generic/fmaxf80.cpp
@@ -28,4 +28,3 @@ LLVM_LIBC_FUNCTION(float80, fmaxf80, (float80 x, float80 y)) {
}
} // namespace LIBC_NAMESPACE_DECL
-
diff --git a/libc/src/math/generic/fminf80.cpp b/libc/src/math/generic/fminf80.cpp
index 506cc82f5558a0..dee3a84f3d6a88 100644
--- a/libc/src/math/generic/fminf80.cpp
+++ b/libc/src/math/generic/fminf80.cpp
@@ -28,4 +28,3 @@ LLVM_LIBC_FUNCTION(float80, fminf80, (float80 x, float80 y)) {
}
} // namespace LIBC_NAMESPACE_DECL
-
diff --git a/libc/test/src/math/smoke/fmaxf80_test.cpp b/libc/test/src/math/smoke/fmaxf80_test.cpp
index b3442c71a427d7..efacaf05b3120c 100644
--- a/libc/test/src/math/smoke/fmaxf80_test.cpp
+++ b/libc/test/src/math/smoke/fmaxf80_test.cpp
@@ -18,4 +18,3 @@
using LIBC_NAMESPACE::fputil::Float80;
LIST_FMAX_TESTS(Fmaxf80, Float80, LIBC_NAMESPACE::fmaxf80)
-
diff --git a/libc/test/src/math/smoke/fminf80_test.cpp b/libc/test/src/math/smoke/fminf80_test.cpp
index 103bec4be5a715..5a8176018f57ee 100644
--- a/libc/test/src/math/smoke/fminf80_test.cpp
+++ b/libc/test/src/math/smoke/fminf80_test.cpp
@@ -18,4 +18,3 @@
using LIBC_NAMESPACE::fputil::Float80;
LIST_FMIN_TESTS(Fminf80, Float80, LIBC_NAMESPACE::fminf80)
-
>From 3b05c708243ae6adc44f56f7b481d61996aad9fd Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 28 Oct 2026 17:28:13 +0530
Subject: [PATCH 3/3] update for hexagon port
---
libc/config/baremetal/hexagon/entrypoints.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libc/config/baremetal/hexagon/entrypoints.txt b/libc/config/baremetal/hexagon/entrypoints.txt
index 9c2c9e66f9eb3b..4594ec6d2b6016 100644
--- a/libc/config/baremetal/hexagon/entrypoints.txt
+++ b/libc/config/baremetal/hexagon/entrypoints.txt
@@ -381,6 +381,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ceill
libc.src.math.copysign
libc.src.math.copysignf
+ libc.src.math.copysignf80
libc.src.math.copysignl
libc.src.math.cos
libc.src.math.cosf
@@ -406,6 +407,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.expm1f
libc.src.math.fabs
libc.src.math.fabsf
+ libc.src.math.fabsf80
libc.src.math.fabsl
libc.src.math.fadd
libc.src.math.faddl
@@ -425,6 +427,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmaf
libc.src.math.fmax
libc.src.math.fmaxf
+ libc.src.math.fmaxf80
libc.src.math.fmaximum
libc.src.math.fmaximum_mag
libc.src.math.fmaximum_mag_num
@@ -440,6 +443,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fmaxl
libc.src.math.fmin
libc.src.math.fminf
+ libc.src.math.fminf80
libc.src.math.fminimum
libc.src.math.fminimum_mag
libc.src.math.fminimum_mag_num
More information about the libc-commits
mailing list