1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -mattr=+architected-sgprs --verify-machineinstrs < %s | FileCheck -check-prefix=GCN-SDAG %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -mattr=+architected-sgprs -global-isel --verify-machineinstrs < %s | FileCheck -check-prefix=GCN-GISEL %s
5 define amdgpu_kernel void @workgroup_id_x(ptr addrspace(1) %ptrx) {
6 ; GCN-SDAG-LABEL: workgroup_id_x:
8 ; GCN-SDAG-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9 ; GCN-SDAG-NEXT: v_mov_b32_e32 v0, 0
10 ; GCN-SDAG-NEXT: v_mov_b32_e32 v1, ttmp9
11 ; GCN-SDAG-NEXT: s_waitcnt lgkmcnt(0)
12 ; GCN-SDAG-NEXT: global_store_dword v0, v1, s[0:1]
13 ; GCN-SDAG-NEXT: s_endpgm
15 ; GCN-GISEL-LABEL: workgroup_id_x:
17 ; GCN-GISEL-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18 ; GCN-GISEL-NEXT: v_mov_b32_e32 v0, ttmp9
19 ; GCN-GISEL-NEXT: v_mov_b32_e32 v1, 0
20 ; GCN-GISEL-NEXT: s_waitcnt lgkmcnt(0)
21 ; GCN-GISEL-NEXT: global_store_dword v1, v0, s[0:1]
22 ; GCN-GISEL-NEXT: s_endpgm
23 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
24 store i32 %idx, ptr addrspace(1) %ptrx
29 define amdgpu_kernel void @workgroup_id_xy(ptr addrspace(1) %ptrx, ptr addrspace(1) %ptry) {
30 ; GCN-SDAG-LABEL: workgroup_id_xy:
32 ; GCN-SDAG-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
33 ; GCN-SDAG-NEXT: v_mov_b32_e32 v0, 0
34 ; GCN-SDAG-NEXT: v_mov_b32_e32 v1, ttmp9
35 ; GCN-SDAG-NEXT: s_waitcnt lgkmcnt(0)
36 ; GCN-SDAG-NEXT: global_store_dword v0, v1, s[0:1]
37 ; GCN-SDAG-NEXT: v_mov_b32_e32 v1, ttmp7
38 ; GCN-SDAG-NEXT: global_store_dword v0, v1, s[2:3]
39 ; GCN-SDAG-NEXT: s_endpgm
41 ; GCN-GISEL-LABEL: workgroup_id_xy:
43 ; GCN-GISEL-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
44 ; GCN-GISEL-NEXT: v_mov_b32_e32 v0, 0
45 ; GCN-GISEL-NEXT: v_mov_b32_e32 v1, ttmp9
46 ; GCN-GISEL-NEXT: s_waitcnt lgkmcnt(0)
47 ; GCN-GISEL-NEXT: global_store_dword v0, v1, s[0:1]
48 ; GCN-GISEL-NEXT: v_mov_b32_e32 v1, ttmp7
49 ; GCN-GISEL-NEXT: global_store_dword v0, v1, s[2:3]
50 ; GCN-GISEL-NEXT: s_endpgm
51 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
52 store i32 %idx, ptr addrspace(1) %ptrx
53 %idy = call i32 @llvm.amdgcn.workgroup.id.y()
54 store i32 %idy, ptr addrspace(1) %ptry
59 define amdgpu_kernel void @workgroup_id_xyz(ptr addrspace(1) %ptrx, ptr addrspace(1) %ptry, ptr addrspace(1) %ptrz) {
60 ; GCN-SDAG-LABEL: workgroup_id_xyz:
62 ; GCN-SDAG-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
63 ; GCN-SDAG-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x10
64 ; GCN-SDAG-NEXT: v_mov_b32_e32 v0, 0
65 ; GCN-SDAG-NEXT: v_mov_b32_e32 v1, ttmp9
66 ; GCN-SDAG-NEXT: s_waitcnt lgkmcnt(0)
67 ; GCN-SDAG-NEXT: global_store_dword v0, v1, s[0:1]
68 ; GCN-SDAG-NEXT: s_and_b32 s0, ttmp7, 0xffff
69 ; GCN-SDAG-NEXT: v_mov_b32_e32 v1, s0
70 ; GCN-SDAG-NEXT: s_lshr_b32 s0, ttmp7, 16
71 ; GCN-SDAG-NEXT: global_store_dword v0, v1, s[2:3]
72 ; GCN-SDAG-NEXT: v_mov_b32_e32 v1, s0
73 ; GCN-SDAG-NEXT: global_store_dword v0, v1, s[6:7]
74 ; GCN-SDAG-NEXT: s_endpgm
76 ; GCN-GISEL-LABEL: workgroup_id_xyz:
78 ; GCN-GISEL-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
79 ; GCN-GISEL-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x10
80 ; GCN-GISEL-NEXT: v_mov_b32_e32 v0, ttmp9
81 ; GCN-GISEL-NEXT: v_mov_b32_e32 v1, 0
82 ; GCN-GISEL-NEXT: s_waitcnt lgkmcnt(0)
83 ; GCN-GISEL-NEXT: global_store_dword v1, v0, s[0:1]
84 ; GCN-GISEL-NEXT: s_and_b32 s0, ttmp7, 0xffff
85 ; GCN-GISEL-NEXT: v_mov_b32_e32 v0, s0
86 ; GCN-GISEL-NEXT: s_lshr_b32 s0, ttmp7, 16
87 ; GCN-GISEL-NEXT: global_store_dword v1, v0, s[2:3]
88 ; GCN-GISEL-NEXT: v_mov_b32_e32 v0, s0
89 ; GCN-GISEL-NEXT: global_store_dword v1, v0, s[6:7]
90 ; GCN-GISEL-NEXT: s_endpgm
91 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
92 store i32 %idx, ptr addrspace(1) %ptrx
93 %idy = call i32 @llvm.amdgcn.workgroup.id.y()
94 store i32 %idy, ptr addrspace(1) %ptry
95 %idz = call i32 @llvm.amdgcn.workgroup.id.z()
96 store i32 %idz, ptr addrspace(1) %ptrz
101 declare i32 @llvm.amdgcn.workgroup.id.x()
102 declare i32 @llvm.amdgcn.workgroup.id.y()
103 declare i32 @llvm.amdgcn.workgroup.id.z()