[libclc] libclc: Stop using r600 asm intrinsic declarations for amdgcn (PR #181975)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 18 01:10:23 PST 2026


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/181975

Really the workitem functions should all be moved to generic code
and use gpuintrin.h. These implementations were copied from there.

>From 6e3e23e6cf395444a39ee2b5f3587dbec46c0375 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 18 Feb 2026 10:07:08 +0100
Subject: [PATCH] libclc: Stop using r600 asm intrinsic declarations for amdgcn

Really the workitem functions should all be moved to generic code
and use gpuintrin.h. These implementations were copied from there.
---
 libclc/opencl/lib/amdgcn/workitem/get_local_size.cl | 10 +++-------
 libclc/opencl/lib/amdgcn/workitem/get_num_groups.cl | 10 +++-------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/libclc/opencl/lib/amdgcn/workitem/get_local_size.cl b/libclc/opencl/lib/amdgcn/workitem/get_local_size.cl
index 8aa24201de573..34e4f2f1b4c19 100644
--- a/libclc/opencl/lib/amdgcn/workitem/get_local_size.cl
+++ b/libclc/opencl/lib/amdgcn/workitem/get_local_size.cl
@@ -8,18 +8,14 @@
 
 #include <clc/opencl/opencl-base.h>
 
-uint __clc_amdgcn_get_local_size_x(void) __asm("llvm.r600.read.local.size.x");
-uint __clc_amdgcn_get_local_size_y(void) __asm("llvm.r600.read.local.size.y");
-uint __clc_amdgcn_get_local_size_z(void) __asm("llvm.r600.read.local.size.z");
-
 _CLC_DEF _CLC_OVERLOAD size_t get_local_size(uint dim) {
   switch (dim) {
   case 0:
-    return __clc_amdgcn_get_local_size_x();
+    return __builtin_amdgcn_workgroup_size_x();
   case 1:
-    return __clc_amdgcn_get_local_size_y();
+    return __builtin_amdgcn_workgroup_size_y();
   case 2:
-    return __clc_amdgcn_get_local_size_z();
+    return __builtin_amdgcn_workgroup_size_z();
   default:
     return 1;
   }
diff --git a/libclc/opencl/lib/amdgcn/workitem/get_num_groups.cl b/libclc/opencl/lib/amdgcn/workitem/get_num_groups.cl
index 11c1ba373aeff..9e8dddb859064 100644
--- a/libclc/opencl/lib/amdgcn/workitem/get_num_groups.cl
+++ b/libclc/opencl/lib/amdgcn/workitem/get_num_groups.cl
@@ -8,18 +8,14 @@
 
 #include <clc/opencl/opencl-base.h>
 
-uint __clc_amdgcn_get_num_groups_x(void) __asm("llvm.r600.read.ngroups.x");
-uint __clc_amdgcn_get_num_groups_y(void) __asm("llvm.r600.read.ngroups.y");
-uint __clc_amdgcn_get_num_groups_z(void) __asm("llvm.r600.read.ngroups.z");
-
 _CLC_DEF _CLC_OVERLOAD size_t get_num_groups(uint dim) {
   switch (dim) {
   case 0:
-    return __clc_amdgcn_get_num_groups_x();
+    return __builtin_amdgcn_grid_size_x() / __builtin_amdgcn_workgroup_size_x();
   case 1:
-    return __clc_amdgcn_get_num_groups_y();
+    return __builtin_amdgcn_grid_size_y() / __builtin_amdgcn_workgroup_size_y();
   case 2:
-    return __clc_amdgcn_get_num_groups_z();
+    return __builtin_amdgcn_grid_size_z() / __builtin_amdgcn_workgroup_size_z();
   default:
     return 1;
   }



More information about the cfe-commits mailing list