https://github.com/krishna2803 updated 
https://github.com/llvm/llvm-project/pull/155575

>From d7930ac1d1d79b0aaf197857abd77f64ab7f3679 Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81...@gmail.com>
Date: Wed, 27 Aug 2025 14:06:39 +0530
Subject: [PATCH 1/6] feat: implement fmodbf16 math function

Signed-off-by: Krishna Pandey <kpandey81...@gmail.com>
---
 libc/src/math/CMakeLists.txt         |  1 +
 libc/src/math/fmodbf16.h             | 21 +++++++++++++++++++++
 libc/src/math/generic/CMakeLists.txt | 14 ++++++++++++++
 libc/src/math/generic/fmodbf16.cpp   | 21 +++++++++++++++++++++
 4 files changed, 57 insertions(+)
 create mode 100644 libc/src/math/fmodbf16.h
 create mode 100644 libc/src/math/generic/fmodbf16.cpp

diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 4b325f773b35f..d2fba849f7e27 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -306,6 +306,7 @@ add_math_entrypoint_object(fmodf)
 add_math_entrypoint_object(fmodl)
 add_math_entrypoint_object(fmodf16)
 add_math_entrypoint_object(fmodf128)
+add_math_entrypoint_object(fmodbf16)
 
 add_math_entrypoint_object(frexp)
 add_math_entrypoint_object(frexpf)
diff --git a/libc/src/math/fmodbf16.h b/libc/src/math/fmodbf16.h
new file mode 100644
index 0000000000000..176dbcc83eda0
--- /dev/null
+++ b/libc/src/math/fmodbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fmodbf16 ----------------------*- 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_MATH_FMODBF16_H
+#define LLVM_LIBC_SRC_MATH_FMODBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 fmodbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMODBF16_H
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index b1fcbf356777a..b9ef116e3dbb9 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4015,6 +4015,20 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.generic.fmod
 )
 
+add_entrypoint_object(
+  fmodbf16
+  SRCS
+    fmodbf16.cpp
+  HDRS
+    ../fmodbf16.h
+  DEPENDS
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.generic.fmod
+)
+
 add_entrypoint_object(
   fromfp
   SRCS
diff --git a/libc/src/math/generic/fmodbf16.cpp 
b/libc/src/math/generic/fmodbf16.cpp
new file mode 100644
index 0000000000000..436ccd1d37f7d
--- /dev/null
+++ b/libc/src/math/generic/fmodbf16.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of fmodbf16 function 
-------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fmodbf16.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/FMod.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, fmodbf16, (bfloat16 x, bfloat16 y)) {
+  return fputil::generic::FMod<bfloat16, uint16_t>::eval(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

>From a77279072840ad095dc551576a9c6d612f33a1b5 Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81...@gmail.com>
Date: Wed, 27 Aug 2025 14:07:02 +0530
Subject: [PATCH 2/6] chore: add smoke tests for fmodbf16 math function

Signed-off-by: Krishna Pandey <kpandey81...@gmail.com>
---
 libc/test/src/math/smoke/CMakeLists.txt    | 17 +++++++++++++++
 libc/test/src/math/smoke/FModTest.h        | 25 +++++++++++-----------
 libc/test/src/math/smoke/fmodbf16_test.cpp | 14 ++++++++++++
 3 files changed, 44 insertions(+), 12 deletions(-)
 create mode 100644 libc/test/src/math/smoke/fmodbf16_test.cpp

diff --git a/libc/test/src/math/smoke/CMakeLists.txt 
b/libc/test/src/math/smoke/CMakeLists.txt
index 226ef2ee71866..7cf463596022f 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4503,6 +4503,23 @@ add_fp_unittest(
   UNIT_TEST_ONLY
 )
 
+add_fp_unittest(
+  fmodbf16_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    fmodbf16_test.cpp
+  HDRS
+    FModTest.h
+  DEPENDS
+    libc.hdr.fenv_macros
+    libc.src.errno.errno
+    libc.src.math.fmodbf16
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fenv_impl
+  UNIT_TEST_ONLY
+)
+
 add_fp_unittest(
   coshf_test
   SUITE
diff --git a/libc/test/src/math/smoke/FModTest.h 
b/libc/test/src/math/smoke/FModTest.h
index 04cbc659ece5d..c72cf93cb7128 100644
--- a/libc/test/src/math/smoke/FModTest.h
+++ b/libc/test/src/math/smoke/FModTest.h
@@ -36,7 +36,8 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest 
{
 
   void testSpecialNumbers(FModFunc f) {
     // fmod (+0, y) == +0 for y != 0.
-    TEST_SPECIAL(zero, T(3.0), zero, false, 0);
+    // FIXME: raises FE_INEXACT for bfloat16
+    // TEST_SPECIAL(zero, T(3.0), zero, false, 0);
     TEST_SPECIAL(zero, min_denormal, zero, false, 0);
     TEST_SPECIAL(zero, -min_denormal, zero, false, 0);
     TEST_SPECIAL(zero, min_normal, zero, false, 0);
@@ -45,7 +46,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest 
{
     TEST_SPECIAL(zero, -max_normal, zero, false, 0);
 
     // fmod (-0, y) == -0 for y != 0.
-    TEST_SPECIAL(neg_zero, T(3.0), neg_zero, false, 0);
+    // TEST_SPECIAL(neg_zero, T(3.0), neg_zero, false, 0);
     TEST_SPECIAL(neg_zero, min_denormal, neg_zero, false, 0);
     TEST_SPECIAL(neg_zero, -min_denormal, neg_zero, false, 0);
     TEST_SPECIAL(neg_zero, min_normal, neg_zero, false, 0);
@@ -99,21 +100,21 @@ class FmodTest : public 
LIBC_NAMESPACE::testing::FEnvSafeTest {
     TEST_SPECIAL(min_denormal, inf, min_denormal, false, 0);
     TEST_SPECIAL(min_normal, inf, min_normal, false, 0);
     TEST_SPECIAL(max_normal, inf, max_normal, false, 0);
-    TEST_SPECIAL(T(3.0), inf, T(3.0), false, 0);
+    // TEST_SPECIAL(T(3.0), inf, T(3.0), false, 0);
     // fmod (x, -inf) == x for x not infinite.
     TEST_SPECIAL(zero, neg_inf, zero, false, 0);
     TEST_SPECIAL(neg_zero, neg_inf, neg_zero, false, 0);
     TEST_SPECIAL(min_denormal, neg_inf, min_denormal, false, 0);
     TEST_SPECIAL(min_normal, neg_inf, min_normal, false, 0);
     TEST_SPECIAL(max_normal, neg_inf, max_normal, false, 0);
-    TEST_SPECIAL(T(3.0), neg_inf, T(3.0), false, 0);
+    // TEST_SPECIAL(T(3.0), neg_inf, T(3.0), false, 0);
 
     TEST_SPECIAL(zero, aNaN, aNaN, false, 0);
     TEST_SPECIAL(zero, neg_aNaN, aNaN, false, 0);
     TEST_SPECIAL(neg_zero, aNaN, aNaN, false, 0);
     TEST_SPECIAL(neg_zero, neg_aNaN, aNaN, false, 0);
-    TEST_SPECIAL(T(1.0), aNaN, aNaN, false, 0);
-    TEST_SPECIAL(T(1.0), neg_aNaN, aNaN, false, 0);
+    // TEST_SPECIAL(T(1.0), aNaN, aNaN, false, 0);
+    // TEST_SPECIAL(T(1.0), neg_aNaN, aNaN, false, 0);
     TEST_SPECIAL(inf, aNaN, aNaN, false, 0);
     TEST_SPECIAL(inf, neg_aNaN, aNaN, false, 0);
     TEST_SPECIAL(neg_inf, aNaN, aNaN, false, 0);
@@ -132,8 +133,8 @@ class FmodTest : public 
LIBC_NAMESPACE::testing::FEnvSafeTest {
     TEST_SPECIAL(neg_aNaN, zero, aNaN, false, 0);
     TEST_SPECIAL(aNaN, neg_zero, aNaN, false, 0);
     TEST_SPECIAL(neg_aNaN, neg_zero, aNaN, false, 0);
-    TEST_SPECIAL(aNaN, T(1.0), aNaN, false, 0);
-    TEST_SPECIAL(neg_aNaN, T(1.0), aNaN, false, 0);
+    // TEST_SPECIAL(aNaN, T(1.0), aNaN, false, 0);
+    // TEST_SPECIAL(neg_aNaN, T(1.0), aNaN, false, 0);
     TEST_SPECIAL(aNaN, inf, aNaN, false, 0);
     TEST_SPECIAL(neg_aNaN, inf, aNaN, false, 0);
     TEST_SPECIAL(aNaN, neg_inf, aNaN, false, 0);
@@ -165,10 +166,10 @@ class FmodTest : public 
LIBC_NAMESPACE::testing::FEnvSafeTest {
     TEST_SPECIAL(neg_sNaN, sNaN, aNaN, false, FE_INVALID);
     TEST_SPECIAL(neg_sNaN, neg_sNaN, aNaN, false, FE_INVALID);
 
-    TEST_SPECIAL(T(6.5), T(2.25), T(2.0), false, 0);
-    TEST_SPECIAL(T(-6.5), T(2.25), T(-2.0), false, 0);
-    TEST_SPECIAL(T(6.5), T(-2.25), T(2.0), false, 0);
-    TEST_SPECIAL(T(-6.5), T(-2.25), T(-2.0), false, 0);
+    // TEST_SPECIAL(T(6.5), T(2.25), T(2.0), false, 0);
+    // TEST_SPECIAL(T(-6.5), T(2.25), T(-2.0), false, 0);
+    // TEST_SPECIAL(T(6.5), T(-2.25), T(2.0), false, 0);
+    // TEST_SPECIAL(T(-6.5), T(-2.25), T(-2.0), false, 0);
 
     TEST_SPECIAL(max_normal, max_normal, zero, false, 0);
     TEST_SPECIAL(max_normal, -max_normal, zero, false, 0);
diff --git a/libc/test/src/math/smoke/fmodbf16_test.cpp 
b/libc/test/src/math/smoke/fmodbf16_test.cpp
new file mode 100644
index 0000000000000..8f30941c89b6a
--- /dev/null
+++ b/libc/test/src/math/smoke/fmodbf16_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for fmodbf16 
--------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "FModTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/fmodbf16.h"
+
+LIST_FMOD_TESTS(bfloat16, LIBC_NAMESPACE::fmodbf16)

>From e5036f72c4b3514d6fb61a8f26bbfc840f41aa52 Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81...@gmail.com>
Date: Wed, 27 Aug 2025 14:07:12 +0530
Subject: [PATCH 3/6] chore: add exahaustive tests for fmodbf16 math function

Signed-off-by: Krishna Pandey <kpandey81...@gmail.com>
---
 libc/test/src/math/exhaustive/CMakeLists.txt  | 16 +++++++
 .../src/math/exhaustive/fmodbf16_test.cpp     | 42 +++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100644 libc/test/src/math/exhaustive/fmodbf16_test.cpp

diff --git a/libc/test/src/math/exhaustive/CMakeLists.txt 
b/libc/test/src/math/exhaustive/CMakeLists.txt
index e40972ea9a879..07c36f424a0c3 100644
--- a/libc/test/src/math/exhaustive/CMakeLists.txt
+++ b/libc/test/src/math/exhaustive/CMakeLists.txt
@@ -377,6 +377,22 @@ add_fp_unittest(
     -lpthread
 )
 
+add_fp_unittest(
+  fmodbf16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    fmodbf16_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.fmodbf16
+    libc.src.__support.FPUtil.bfloat16
+  LINK_LIBRARIES
+    -lpthread
+)
+
 add_fp_unittest(
   coshf_test
   NO_RUN_POSTBUILD
diff --git a/libc/test/src/math/exhaustive/fmodbf16_test.cpp 
b/libc/test/src/math/exhaustive/fmodbf16_test.cpp
new file mode 100644
index 0000000000000..5c0fd7d12bd19
--- /dev/null
+++ b/libc/test/src/math/exhaustive/fmodbf16_test.cpp
@@ -0,0 +1,42 @@
+//===-- Exhaustive test for fmodbf16 
--------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "exhaustive_test.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/fmodbf16.h"
+#include "utils/MPFRWrapper/MPFRUtils.h"
+
+namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
+
+using LlvmLibcFmodf16ExhaustiveTest =
+    LlvmLibcBinaryOpExhaustiveMathTest<bfloat16, mpfr::Operation::Fmod,
+                                       LIBC_NAMESPACE::fmodbf16>;
+
+// range: [0, inf]
+static constexpr uint16_t POS_START = 0x0000U;
+static constexpr uint16_t POS_STOP = 0x7f80U;
+
+// range: [-0, -inf]
+static constexpr uint16_t NEG_START = 0x8000U;
+static constexpr uint16_t NEG_STOP = 0xff80U;
+
+TEST_F(LlvmLibcFmodf16ExhaustiveTest, PostivePositiveRange) {
+  test_full_range_all_roundings(POS_START, POS_STOP, POS_START, POS_STOP);
+}
+
+TEST_F(LlvmLibcFmodf16ExhaustiveTest, PostiveNegativeRange) {
+  test_full_range_all_roundings(POS_START, POS_STOP, NEG_START, NEG_STOP);
+}
+
+TEST_F(LlvmLibcFmodf16ExhaustiveTest, NegativePositiveRange) {
+  test_full_range_all_roundings(NEG_START, NEG_STOP, POS_START, POS_STOP);
+}
+
+TEST_F(LlvmLibcFmodf16ExhaustiveTest, NegativeNegativeRange) {
+  test_full_range_all_roundings(NEG_START, NEG_STOP, POS_START, POS_STOP);
+}

>From a90272319cf72f2590e07aa130f39833d30b05de Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81...@gmail.com>
Date: Wed, 27 Aug 2025 14:07:22 +0530
Subject: [PATCH 4/6] chore: update entrypoints

Signed-off-by: Krishna Pandey <kpandey81...@gmail.com>
---
 libc/config/baremetal/aarch64/entrypoints.txt | 1 +
 libc/config/baremetal/arm/entrypoints.txt     | 1 +
 libc/config/baremetal/riscv/entrypoints.txt   | 1 +
 libc/config/darwin/aarch64/entrypoints.txt    | 1 +
 libc/config/darwin/x86_64/entrypoints.txt     | 1 +
 libc/config/gpu/amdgpu/entrypoints.txt        | 1 +
 libc/config/gpu/nvptx/entrypoints.txt         | 1 +
 libc/config/linux/aarch64/entrypoints.txt     | 1 +
 libc/config/linux/arm/entrypoints.txt         | 1 +
 libc/config/linux/riscv/entrypoints.txt       | 1 +
 libc/config/linux/x86_64/entrypoints.txt      | 1 +
 libc/config/windows/entrypoints.txt           | 1 +
 12 files changed, 12 insertions(+)

diff --git a/libc/config/baremetal/aarch64/entrypoints.txt 
b/libc/config/baremetal/aarch64/entrypoints.txt
index 637be4f19d5b7..782769e2c0ef9 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -788,6 +788,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/baremetal/arm/entrypoints.txt 
b/libc/config/baremetal/arm/entrypoints.txt
index 19aedb0a8677d..f112c2b36fdf3 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -791,6 +791,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/baremetal/riscv/entrypoints.txt 
b/libc/config/baremetal/riscv/entrypoints.txt
index cfbb598cbe4bf..53e5914b9ec32 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -791,6 +791,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/darwin/aarch64/entrypoints.txt 
b/libc/config/darwin/aarch64/entrypoints.txt
index 26e97d8993039..b4e210ad3ae0b 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -621,6 +621,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/darwin/x86_64/entrypoints.txt 
b/libc/config/darwin/x86_64/entrypoints.txt
index 0556a6f7a4715..95392f7718849 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -264,6 +264,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt 
b/libc/config/gpu/amdgpu/entrypoints.txt
index 8817972480aac..737d1bb3ac61c 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -647,6 +647,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/gpu/nvptx/entrypoints.txt 
b/libc/config/gpu/nvptx/entrypoints.txt
index db762ed5c74d6..c06d63576bbd3 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -649,6 +649,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index 0a2ebfa3f8720..9aeb6a7361cd5 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -876,6 +876,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/linux/arm/entrypoints.txt 
b/libc/config/linux/arm/entrypoints.txt
index ea1c5c0558272..591c57d479dc2 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -491,6 +491,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/linux/riscv/entrypoints.txt 
b/libc/config/linux/riscv/entrypoints.txt
index d5180b77c3af0..b2cd511506607 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -894,6 +894,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index c64db2cc3548f..d5db2606a9887 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -927,6 +927,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
diff --git a/libc/config/windows/entrypoints.txt 
b/libc/config/windows/entrypoints.txt
index 9f825bdf657e9..2da48c32d0af3 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -337,6 +337,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.fmodbf16
   libc.src.math.frexpbf16
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16

>From d45139336143155944efb02e2fbe8800802a1c7e Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81...@gmail.com>
Date: Wed, 27 Aug 2025 14:07:27 +0530
Subject: [PATCH 5/6] docs: add smoke tests for fmodbf16 math function

Signed-off-by: Krishna Pandey <kpandey81...@gmail.com>
---
 libc/docs/headers/math/index.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/docs/headers/math/index.rst b/libc/docs/headers/math/index.rst
index a707b37894afc..4520f56137bd7 100644
--- a/libc/docs/headers/math/index.rst
+++ b/libc/docs/headers/math/index.rst
@@ -175,7 +175,7 @@ Basic Operations
 
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | fminimum_num     | |check|          | |check|         | |check|              
  | |check|              | |check|                | |check|                | 
7.12.12.9              | F.10.9.5                   |
 
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
-| fmod             | |check|          | |check|         | |check|              
  | |check|              | |check|                |                        | 
7.12.10.1              | F.10.7.1                   |
+| fmod             | |check|          | |check|         | |check|              
  | |check|              | |check|                | |check|                | 
7.12.10.1              | F.10.7.1                   |
 
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | fmul             | N/A              | |check|         | |check|              
  | N/A                  | |check|\*              | N/A                    | 
7.12.14.3              | F.10.11                    |
 
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+

>From 0e2a7d948d60553bf59e391856fd834522ff9b63 Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81...@gmail.com>
Date: Wed, 27 Aug 2025 14:40:40 +0530
Subject: [PATCH 6/6] fix: FE_INEXACT exception

Signed-off-by: Krishna Pandey <kpandey81...@gmail.com>
---
 libc/test/src/math/smoke/FModTest.h | 59 +++++++++++++++++------------
 1 file changed, 34 insertions(+), 25 deletions(-)

diff --git a/libc/test/src/math/smoke/FModTest.h 
b/libc/test/src/math/smoke/FModTest.h
index c72cf93cb7128..02729f7ec3555 100644
--- a/libc/test/src/math/smoke/FModTest.h
+++ b/libc/test/src/math/smoke/FModTest.h
@@ -31,13 +31,22 @@ class FmodTest : public 
LIBC_NAMESPACE::testing::FEnvSafeTest {
 
   DECLARE_SPECIAL_CONSTANTS(T)
 
+  static constexpr T one = T(1.0);
+  static constexpr T two = T(2.0);
+  static constexpr T neg_two = T(-2.0);
+  static constexpr T three = T(3.0);
+  static constexpr T neg_one_point_one = T(-1.1);
+  static constexpr T six_halves = T(6.5);
+  static constexpr T neg_six_halves = T(-6.5);
+  static constexpr T two_quaters = T(2.25);
+  static constexpr T neg_two_quaters = T(-2.25);
+
 public:
   typedef T (*FModFunc)(T, T);
 
   void testSpecialNumbers(FModFunc f) {
     // fmod (+0, y) == +0 for y != 0.
-    // FIXME: raises FE_INEXACT for bfloat16
-    // TEST_SPECIAL(zero, T(3.0), zero, false, 0);
+    TEST_SPECIAL(zero, three, zero, false, 0);
     TEST_SPECIAL(zero, min_denormal, zero, false, 0);
     TEST_SPECIAL(zero, -min_denormal, zero, false, 0);
     TEST_SPECIAL(zero, min_normal, zero, false, 0);
@@ -46,7 +55,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest 
{
     TEST_SPECIAL(zero, -max_normal, zero, false, 0);
 
     // fmod (-0, y) == -0 for y != 0.
-    // TEST_SPECIAL(neg_zero, T(3.0), neg_zero, false, 0);
+    TEST_SPECIAL(neg_zero, three, neg_zero, false, 0);
     TEST_SPECIAL(neg_zero, min_denormal, neg_zero, false, 0);
     TEST_SPECIAL(neg_zero, -min_denormal, neg_zero, false, 0);
     TEST_SPECIAL(neg_zero, min_normal, neg_zero, false, 0);
@@ -55,8 +64,8 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest 
{
     TEST_SPECIAL(neg_zero, -max_normal, neg_zero, false, 0);
 
     // fmod (+inf, y) == aNaN plus invalid exception.
-    TEST_SPECIAL(inf, T(3.0), aNaN, true, FE_INVALID);
-    TEST_SPECIAL(inf, T(-1.1), aNaN, true, FE_INVALID);
+    TEST_SPECIAL(inf, three, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(inf, neg_one_point_one, aNaN, true, FE_INVALID);
     TEST_SPECIAL(inf, zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(inf, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(inf, min_denormal, aNaN, true, FE_INVALID);
@@ -66,8 +75,8 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest 
{
     TEST_SPECIAL(inf, neg_inf, aNaN, true, FE_INVALID);
 
     // fmod (-inf, y) == aNaN plus invalid exception.
-    TEST_SPECIAL(neg_inf, T(3.0), aNaN, true, FE_INVALID);
-    TEST_SPECIAL(neg_inf, T(-1.1), aNaN, true, FE_INVALID);
+    TEST_SPECIAL(neg_inf, three, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(neg_inf, neg_one_point_one, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_inf, zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_inf, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_inf, min_denormal, aNaN, true, FE_INVALID);
@@ -77,8 +86,8 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest 
{
     TEST_SPECIAL(neg_inf, neg_inf, aNaN, true, FE_INVALID);
 
     // fmod (x, +0) == aNaN plus invalid exception.
-    TEST_SPECIAL(T(3.0), zero, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(T(-1.1), zero, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(three, zero, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(neg_one_point_one, zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(zero, zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_zero, zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(min_denormal, zero, aNaN, true, FE_INVALID);
@@ -86,8 +95,8 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest 
{
     TEST_SPECIAL(max_normal, zero, aNaN, true, FE_INVALID);
 
     // fmod (x, -0) == aNaN plus invalid exception.
-    TEST_SPECIAL(T(3.0), neg_zero, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(T(-1.1), neg_zero, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(three, neg_zero, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(neg_one_point_one, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(zero, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_zero, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(min_denormal, neg_zero, aNaN, true, FE_INVALID);
@@ -100,21 +109,21 @@ class FmodTest : public 
LIBC_NAMESPACE::testing::FEnvSafeTest {
     TEST_SPECIAL(min_denormal, inf, min_denormal, false, 0);
     TEST_SPECIAL(min_normal, inf, min_normal, false, 0);
     TEST_SPECIAL(max_normal, inf, max_normal, false, 0);
-    // TEST_SPECIAL(T(3.0), inf, T(3.0), false, 0);
+    TEST_SPECIAL(three, inf, three, false, 0);
     // fmod (x, -inf) == x for x not infinite.
     TEST_SPECIAL(zero, neg_inf, zero, false, 0);
     TEST_SPECIAL(neg_zero, neg_inf, neg_zero, false, 0);
     TEST_SPECIAL(min_denormal, neg_inf, min_denormal, false, 0);
     TEST_SPECIAL(min_normal, neg_inf, min_normal, false, 0);
     TEST_SPECIAL(max_normal, neg_inf, max_normal, false, 0);
-    // TEST_SPECIAL(T(3.0), neg_inf, T(3.0), false, 0);
+    TEST_SPECIAL(three, neg_inf, three, false, 0);
 
     TEST_SPECIAL(zero, aNaN, aNaN, false, 0);
     TEST_SPECIAL(zero, neg_aNaN, aNaN, false, 0);
     TEST_SPECIAL(neg_zero, aNaN, aNaN, false, 0);
     TEST_SPECIAL(neg_zero, neg_aNaN, aNaN, false, 0);
-    // TEST_SPECIAL(T(1.0), aNaN, aNaN, false, 0);
-    // TEST_SPECIAL(T(1.0), neg_aNaN, aNaN, false, 0);
+    TEST_SPECIAL(one, aNaN, aNaN, false, 0);
+    TEST_SPECIAL(one, neg_aNaN, aNaN, false, 0);
     TEST_SPECIAL(inf, aNaN, aNaN, false, 0);
     TEST_SPECIAL(inf, neg_aNaN, aNaN, false, 0);
     TEST_SPECIAL(neg_inf, aNaN, aNaN, false, 0);
@@ -123,8 +132,8 @@ class FmodTest : public 
LIBC_NAMESPACE::testing::FEnvSafeTest {
     TEST_SPECIAL(zero, neg_sNaN, aNaN, false, FE_INVALID);
     TEST_SPECIAL(neg_zero, sNaN, aNaN, false, FE_INVALID);
     TEST_SPECIAL(neg_zero, neg_sNaN, aNaN, false, FE_INVALID);
-    TEST_SPECIAL(T(1.0), sNaN, aNaN, false, FE_INVALID);
-    TEST_SPECIAL(T(1.0), neg_sNaN, aNaN, false, FE_INVALID);
+    TEST_SPECIAL(one, sNaN, aNaN, false, FE_INVALID);
+    TEST_SPECIAL(one, neg_sNaN, aNaN, false, FE_INVALID);
     TEST_SPECIAL(inf, sNaN, aNaN, false, FE_INVALID);
     TEST_SPECIAL(inf, neg_sNaN, aNaN, false, FE_INVALID);
     TEST_SPECIAL(neg_inf, sNaN, aNaN, false, FE_INVALID);
@@ -133,8 +142,8 @@ class FmodTest : public 
LIBC_NAMESPACE::testing::FEnvSafeTest {
     TEST_SPECIAL(neg_aNaN, zero, aNaN, false, 0);
     TEST_SPECIAL(aNaN, neg_zero, aNaN, false, 0);
     TEST_SPECIAL(neg_aNaN, neg_zero, aNaN, false, 0);
-    // TEST_SPECIAL(aNaN, T(1.0), aNaN, false, 0);
-    // TEST_SPECIAL(neg_aNaN, T(1.0), aNaN, false, 0);
+    TEST_SPECIAL(aNaN, one, aNaN, false, 0);
+    TEST_SPECIAL(neg_aNaN, one, aNaN, false, 0);
     TEST_SPECIAL(aNaN, inf, aNaN, false, 0);
     TEST_SPECIAL(neg_aNaN, inf, aNaN, false, 0);
     TEST_SPECIAL(aNaN, neg_inf, aNaN, false, 0);
@@ -143,8 +152,8 @@ class FmodTest : public 
LIBC_NAMESPACE::testing::FEnvSafeTest {
     TEST_SPECIAL(neg_sNaN, zero, aNaN, false, FE_INVALID);
     TEST_SPECIAL(sNaN, neg_zero, aNaN, false, FE_INVALID);
     TEST_SPECIAL(neg_sNaN, neg_zero, aNaN, false, FE_INVALID);
-    TEST_SPECIAL(sNaN, T(1.0), aNaN, false, FE_INVALID);
-    TEST_SPECIAL(neg_sNaN, T(1.0), aNaN, false, FE_INVALID);
+    TEST_SPECIAL(sNaN, one, aNaN, false, FE_INVALID);
+    TEST_SPECIAL(neg_sNaN, one, aNaN, false, FE_INVALID);
     TEST_SPECIAL(sNaN, inf, aNaN, false, FE_INVALID);
     TEST_SPECIAL(neg_sNaN, inf, aNaN, false, FE_INVALID);
     TEST_SPECIAL(sNaN, neg_inf, aNaN, false, FE_INVALID);
@@ -166,10 +175,10 @@ class FmodTest : public 
LIBC_NAMESPACE::testing::FEnvSafeTest {
     TEST_SPECIAL(neg_sNaN, sNaN, aNaN, false, FE_INVALID);
     TEST_SPECIAL(neg_sNaN, neg_sNaN, aNaN, false, FE_INVALID);
 
-    // TEST_SPECIAL(T(6.5), T(2.25), T(2.0), false, 0);
-    // TEST_SPECIAL(T(-6.5), T(2.25), T(-2.0), false, 0);
-    // TEST_SPECIAL(T(6.5), T(-2.25), T(2.0), false, 0);
-    // TEST_SPECIAL(T(-6.5), T(-2.25), T(-2.0), false, 0);
+    TEST_SPECIAL(six_halves, two_quaters, two, false, 0);
+    TEST_SPECIAL(neg_six_halves, two_quaters, neg_two, false, 0);
+    TEST_SPECIAL(six_halves, neg_two_quaters, two, false, 0);
+    TEST_SPECIAL(neg_six_halves, neg_two_quaters, neg_two, false, 0);
 
     TEST_SPECIAL(max_normal, max_normal, zero, false, 0);
     TEST_SPECIAL(max_normal, -max_normal, zero, false, 0);

_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to