[libc-commits] [libc] [libc] Use `rint` builtin for rounding on the GPU (PR #98345)

Matt Arsenault via libc-commits libc-commits at lists.llvm.org
Wed Jul 10 11:13:42 PDT 2024


================
@@ -17,6 +17,18 @@
 #include "x86_64/nearest_integer.h"
 #elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
 #include "aarch64/nearest_integer.h"
+#elif defined(LIBC_TARGET_ARCH_IS_GPU)
+
+namespace LIBC_NAMESPACE {
+namespace fputil {
+
+LIBC_INLINE float nearest_integer(float x) { return __builtin_rintf(x); }
----------------
arsenm wrote:

rint/nearbyint/roundeven are the same under not-strictfp and ignoring exceptions and dynamic rounding mode  We shouldn't have the 3 intrinsics for them. 

https://github.com/llvm/llvm-project/pull/98345


More information about the libc-commits mailing list