[libc-commits] [libc] fa2b51c - [libc][GPU] Use generic implementation for remainder in GPU libc (#241657)

via libc-commits libc-commits at lists.llvm.org
Wed Nov 11 22:53:01 PST 2026


Author: jinge90
Date: 2026-11-12T14:52:55+08:00
New Revision: fa2b51c0141a3f25c84b0d33cb4b5ec42820d57d

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

LOG: [libc][GPU] Use generic implementation for remainder in GPU libc (#241657)

Current implementation for remainder and remainderf for GPU uses builtin
which is not converted into llvm instrinisc, this PR switches to generic
implementation.

---------

Signed-off-by: jinge90 <ge.jin at intel.com>

Added: 
    

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

Removed: 
    libc/src/math/amdgpu/remainder.cpp
    libc/src/math/amdgpu/remainderf.cpp
    libc/src/math/nvptx/remainder.cpp
    libc/src/math/nvptx/remainderf.cpp


################################################################################
diff  --git a/libc/src/math/amdgpu/CMakeLists.txt b/libc/src/math/amdgpu/CMakeLists.txt
index d05d519b74b4fe..f6edab862728cb 100644
--- a/libc/src/math/amdgpu/CMakeLists.txt
+++ b/libc/src/math/amdgpu/CMakeLists.txt
@@ -142,22 +142,6 @@ add_entrypoint_object(
     ../nearbyintf.h
 )
 
-add_entrypoint_object(
-  remainder
-  SRCS
-    remainder.cpp
-  HDRS
-    ../remainder.h
-)
-
-add_entrypoint_object(
-  remainderf
-  SRCS
-    remainderf.cpp
-  HDRS
-    ../remainderf.h
-)
-
 add_entrypoint_object(
   rint
   SRCS

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

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

diff  --git a/libc/src/math/nvptx/CMakeLists.txt b/libc/src/math/nvptx/CMakeLists.txt
index 78797092622a3d..42159cab348f1c 100644
--- a/libc/src/math/nvptx/CMakeLists.txt
+++ b/libc/src/math/nvptx/CMakeLists.txt
@@ -126,22 +126,6 @@ add_entrypoint_object(
     ../nearbyintf.h
 )
 
-add_entrypoint_object(
-  remainder
-  SRCS
-    remainder.cpp
-  HDRS
-    ../remainder.h
-)
-
-add_entrypoint_object(
-  remainderf
-  SRCS
-    remainderf.cpp
-  HDRS
-    ../remainderf.h
-)
-
 add_entrypoint_object(
   rint
   SRCS

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

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


        


More information about the libc-commits mailing list