[llvm] [AMDGPU] Add more cases to the "this is a wave ID" recognizer (PR #177713)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 27 09:15:14 PST 2026


================
@@ -131,6 +131,54 @@ define amdgpu_kernel void @workitem_id_x_div_wavefront_size(ptr %o) #3 !reqd_wor
   ret void
 }
 
+; CHECK-LABEL: UniformityInfo for function 'workitem_id_x_masked'
+; CHECK: DIVERGENT: %id.x = call i32 @llvm.amdgcn.workitem.id.x()
+; CHECK-NOT: DIVERGENT
+define amdgpu_kernel void @workitem_id_x_masked(ptr %o) #3 !reqd_work_group_size !5 {
+  %id.x = call i32 @llvm.amdgcn.workitem.id.x()
+  %id.sg.shl.6 = and i32 %id.x, 192
+  store i32 %id.sg.shl.6, ptr %o
+  ret void
+}
+
+; CHECK-LABEL: UniformityInfo for function 'workitem_id_x_zext_masked'
+; CHECK: DIVERGENT: %id.x = call i32 @llvm.amdgcn.workitem.id.x()
+; CHECK: DIVERGENT: %id.x.zext = zext i32 %id.x to i64
+; CHECK-NOT: DIVERGENT
+define amdgpu_kernel void @workitem_id_x_zext_masked(ptr %o) #3 !reqd_work_group_size !5 {
+  %id.x = call i32 @llvm.amdgcn.workitem.id.x()
+  %id.x.zext = zext i32 %id.x to i64
----------------
arsenm wrote:

Needs to test the multi use case then? 

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


More information about the llvm-commits mailing list