[flang-commits] [flang] 602f308 - [flang][cuda] Add interface for __saturatef (#153705)
via flang-commits
flang-commits at lists.llvm.org
Thu Aug 14 15:55:20 PDT 2025
Author: Valentin Clement (バレンタイン クレメン)
Date: 2025-08-14T15:55:17-07:00
New Revision: 602f308d4fcc84d90d49fb708f757589bca68d4e
URL: https://github.com/llvm/llvm-project/commit/602f308d4fcc84d90d49fb708f757589bca68d4e
DIFF: https://github.com/llvm/llvm-project/commit/602f308d4fcc84d90d49fb708f757589bca68d4e.diff
LOG: [flang][cuda] Add interface for __saturatef (#153705)
Added:
Modified:
flang/module/cudadevice.f90
flang/test/Lower/CUDA/cuda-libdevice.cuf
Removed:
################################################################################
diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index b5a92c63f19ed..598d154eb3d8a 100644
--- a/flang/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -325,6 +325,13 @@ attributes(device) real(8) function rsqrt(x) bind(c,name='__nv_rsqrt')
end function
end interface
+ interface saturate
+ attributes(device) real function __saturatef(r) bind(c, name='__nv_saturatef')
+ !dir$ ignore_tkr (d) r
+ real, value :: r
+ end function
+ end interface
+
interface __sad
attributes(device) integer function __sad(i,j,k) bind(c, name='__nv_sad')
!dir$ ignore_tkr (d) i, (d) j, (d) k
diff --git a/flang/test/Lower/CUDA/cuda-libdevice.cuf b/flang/test/Lower/CUDA/cuda-libdevice.cuf
index 68fd443d39f57..ecce60599a358 100644
--- a/flang/test/Lower/CUDA/cuda-libdevice.cuf
+++ b/flang/test/Lower/CUDA/cuda-libdevice.cuf
@@ -162,6 +162,15 @@ end subroutine
! CHECK: %{{.*}} = fir.call @__nv_double2ull_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
! CHECK: %{{.*}} = fir.call @__nv_double2ull_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
+attributes(global) subroutine test_saturatef()
+ real :: res
+ real :: r
+ res = __saturatef(r)
+end subroutine
+
+! CHECK-LABEL: _QPtest_saturatef
+! CHECK: %{{.*}} = fir.call @__nv_saturatef(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
+
attributes(global) subroutine test_float2ll_rX()
integer(8) :: res
real :: r
More information about the flang-commits
mailing list