Skip to content

Conversation

@clementval
Copy link
Contributor

No description provided.

@clementval clementval requested a review from wangzpgi August 15, 2025 04:23
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Aug 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 15, 2025

@llvm/pr-subscribers-flang-fir-hlfir

Author: Valentin Clement (バレンタイン クレメン) (clementval)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/153742.diff

2 Files Affected:

  • (modified) flang/module/cudadevice.f90 (+7)
  • (modified) flang/test/Lower/CUDA/cuda-libdevice.cuf (+9)
diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index ffc3a3b170ca6..3ffac40c97279 100644
--- a/flang/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -399,6 +399,13 @@ attributes(device) subroutine sincospi(x, y, z) bind(c,name='__nv_sincospi')
     end function
   end interface
 
+  interface __fdividef
+    attributes(device) real function __fdividef(r,d) bind(c, name='__nv_fast_fdividef')
+      !dir$ ignore_tkr (d) r, (d) d
+      real, value :: r,d
+    end function
+  end interface
+
   interface __sinf
     attributes(device) real function __sinf(r) bind(c, name='__nv_sinf')
       !dir$ ignore_tkr (d) r
diff --git a/flang/test/Lower/CUDA/cuda-libdevice.cuf b/flang/test/Lower/CUDA/cuda-libdevice.cuf
index f9c5dcc5fc4c3..c560d4c884317 100644
--- a/flang/test/Lower/CUDA/cuda-libdevice.cuf
+++ b/flang/test/Lower/CUDA/cuda-libdevice.cuf
@@ -244,3 +244,12 @@ end subroutine
 ! CHECK: %{{.*}} = fir.call @__nv_float2uint_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
 ! CHECK: %{{.*}} = fir.call @__nv_float2uint_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
 ! CHECK: %{{.*}} = fir.call @__nv_float2uint_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
+
+attributes(global) subroutine test_fdividef()
+  real :: res
+  real :: r
+  res = __fdividef(r, r)
+end subroutine
+
+! CHECK-LABEL: _QPtest_fdividef
+! CHECK: %{{.*}} = fir.call @__nv_fast_fdividef(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32, f32) -> f32

@clementval clementval merged commit 0e4af72 into llvm:main Aug 15, 2025
5 of 8 checks passed
@clementval clementval deleted the cuf_fdivide branch August 15, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:fir-hlfir flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants