From e7620a7d8b39da1791e23c01a19b8f7e9bb7c2a3 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Tue, 12 Aug 2025 13:03:21 -0700 Subject: [PATCH] [flang][cuda] Add bind name for __clz interface --- flang/module/cudadevice.f90 | 4 ++-- flang/test/Lower/CUDA/cuda-device-proc.cuf | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90 index 1b3c98b3e3f96..bb88ebcef9a0f 100644 --- a/flang/module/cudadevice.f90 +++ b/flang/module/cudadevice.f90 @@ -732,11 +732,11 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi') end interface interface __clz - attributes(device) integer function __clz(i) bind(c) + attributes(device) integer function __clz(i) bind(c, name='__nv_clz') !dir$ ignore_tkr (d) i integer, value :: i end function - attributes(device) integer function __clzll(i) bind(c) + attributes(device) integer function __clzll(i) bind(c, name='__nv_clzll') !dir$ ignore_tkr (d) i integer(8), value :: i end function diff --git a/flang/test/Lower/CUDA/cuda-device-proc.cuf b/flang/test/Lower/CUDA/cuda-device-proc.cuf index 24600291b788a..1bb7aa565109c 100644 --- a/flang/test/Lower/CUDA/cuda-device-proc.cuf +++ b/flang/test/Lower/CUDA/cuda-device-proc.cuf @@ -58,6 +58,8 @@ attributes(global) subroutine devsub() res = __ffs(al) res = __brev(ai) resl = __brev(al) + res = __clz(ai) + res = __clz(al) end ! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc} @@ -104,6 +106,8 @@ end ! CHECK: %{{.*}} = fir.call @__nv_ffsll(%{{.*}}) proc_attrs fastmath : (i64) -> i32 ! CHECK: %{{.*}} = fir.call @__nv_brev(%{{.*}}) proc_attrs fastmath : (i32) -> i32 ! CHECK: %{{.*}} = fir.call @__nv_brevll(%{{.*}}) proc_attrs fastmath : (i64) -> i64 +! CHECK: %{{.*}} = fir.call @__nv_clz(%{{.*}}) proc_attrs fastmath : (i32) -> i32 +! CHECK: %{{.*}} = fir.call @__nv_clzll(%{{.*}}) proc_attrs fastmath : (i64) -> i32 subroutine host1() integer, device :: a(32)