[libc-commits] [libc] b232d11 - [libc] Fix math failures for fmod on NVPTX (#213168)

via libc-commits libc-commits at lists.llvm.org
Fri Jul 31 09:21:31 PDT 2026


Author: Joseph Huber
Date: 2026-07-31T11:21:26-05:00
New Revision: b232d110b082c597ac518d37624d16aac3f71ab5

URL: https://github.com/llvm/llvm-project/commit/b232d110b082c597ac518d37624d16aac3f71ab5
DIFF: https://github.com/llvm/llvm-project/commit/b232d110b082c597ac518d37624d16aac3f71ab5.diff

LOG: [libc] Fix math failures for fmod on NVPTX (#213168)

Summary:
Fixes some failing tests. Fmod's builtin has improper handling in the
NVPTX instruction so we should just use the generic version for now. The
Float128 implementation seems to have had some undefined behavior for
out of range behavior that only showed up now. Hopefully someone can
tell me if this is fixed correctly.

Added: 
    

Modified: 
    libc/src/math/nvptx/CMakeLists.txt

Removed: 
    libc/src/math/nvptx/fmod.cpp
    libc/src/math/nvptx/fmodf.cpp


################################################################################
diff  --git a/libc/src/math/nvptx/CMakeLists.txt b/libc/src/math/nvptx/CMakeLists.txt
index e27c316ff20ca..78797092622a3 100644
--- a/libc/src/math/nvptx/CMakeLists.txt
+++ b/libc/src/math/nvptx/CMakeLists.txt
@@ -110,22 +110,6 @@ add_entrypoint_object(
     ../fminf.h
 )
 
-add_entrypoint_object(
-  fmod
-  SRCS
-    fmod.cpp
-  HDRS
-    ../fmod.h
-)
-
-add_entrypoint_object(
-  fmodf
-  SRCS
-    fmodf.cpp
-  HDRS
-    ../fmodf.h
-)
-
 add_entrypoint_object(
   nearbyint
   SRCS

diff  --git a/libc/src/math/nvptx/fmod.cpp b/libc/src/math/nvptx/fmod.cpp
deleted file mode 100644
index 49d19c4decb96..0000000000000
--- a/libc/src/math/nvptx/fmod.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the fmod function for GPU -----------------------===//
-//
-// 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/fmod.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(double, fmod, (double x, double y)) {
-  return __builtin_fmod(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/math/nvptx/fmodf.cpp b/libc/src/math/nvptx/fmodf.cpp
deleted file mode 100644
index 8fbcb0cc2ad9e..0000000000000
--- a/libc/src/math/nvptx/fmodf.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- Implementation of the fmodf function for GPU ----------------------===//
-//
-// 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/fmodf.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(float, fmodf, (float x, float y)) {
-  return __builtin_fmodf(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL


        


More information about the libc-commits mailing list