Skip to content

Commit

Permalink
[AMDGPU] Mark workgroup_id intrinsics always uniform (llvm#102042)
Browse files Browse the repository at this point in the history
  • Loading branch information
rampitec authored Aug 5, 2024
1 parent 1fb1a5d commit bbe0663
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPUSearchableTables.td
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,6 @@ def : AlwaysUniform<int_amdgcn_icmp>;
def : AlwaysUniform<int_amdgcn_fcmp>;
def : AlwaysUniform<int_amdgcn_ballot>;
def : AlwaysUniform<int_amdgcn_if_break>;
def : AlwaysUniform<int_amdgcn_workgroup_id_x>;
def : AlwaysUniform<int_amdgcn_workgroup_id_y>;
def : AlwaysUniform<int_amdgcn_workgroup_id_z>;
27 changes: 27 additions & 0 deletions llvm/test/Analysis/UniformityAnalysis/AMDGPU/always_uniform.ll
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,38 @@ define void @no_divergent_args_if_inreg(i32 inreg %i32, i1 inreg %i1) {
ret void
}

; CHECK-LABEL: for function 'workgroup_id_x':
; CHECK: ALL VALUES UNIFORM
define void @workgroup_id_x(ptr addrspace(1) inreg %out) {
%result = call i32 @llvm.amdgcn.workgroup.id.x()
store i32 %result, ptr addrspace(1) %out, align 4
ret void
}

; CHECK-LABEL: for function 'workgroup_id_y':
; CHECK: ALL VALUES UNIFORM
define void @workgroup_id_y(ptr addrspace(1) inreg %out) {
%result = call i32 @llvm.amdgcn.workgroup.id.y()
store i32 %result, ptr addrspace(1) %out, align 4
ret void
}

; CHECK-LABEL: for function 'workgroup_id_z':
; CHECK: ALL VALUES UNIFORM
define void @workgroup_id_z(ptr addrspace(1) inreg %out) {
%result = call i32 @llvm.amdgcn.workgroup.id.z()
store i32 %result, ptr addrspace(1) %out, align 4
ret void
}

declare i32 @llvm.amdgcn.workitem.id.x() #0
declare i32 @llvm.amdgcn.readfirstlane(i32) #0
declare i64 @llvm.amdgcn.icmp.i32(i32, i32, i32) #1
declare i64 @llvm.amdgcn.fcmp.i32(float, float, i32) #1
declare i64 @llvm.amdgcn.ballot.i32(i1) #1
declare i32 @llvm.amdgcn.workgroup.id.x() #0
declare i32 @llvm.amdgcn.workgroup.id.y() #0
declare i32 @llvm.amdgcn.workgroup.id.z() #0

attributes #0 = { nounwind readnone }
attributes #1 = { nounwind readnone convergent }
Expand Down

0 comments on commit bbe0663

Please sign in to comment.