1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -mattr=+architected-sgprs --verify-machineinstrs < %s | FileCheck -check-prefix=GFX9-SDAG %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -mattr=+architected-sgprs -global-isel --verify-machineinstrs < %s | FileCheck -check-prefix=GFX9-GISEL %s
5 define amdgpu_cs void @_amdgpu_cs_main() {
6 ; GFX9-SDAG-LABEL: _amdgpu_cs_main:
7 ; GFX9-SDAG: ; %bb.0: ; %.entry
8 ; GFX9-SDAG-NEXT: s_lshr_b32 s2, ttmp7, 16
9 ; GFX9-SDAG-NEXT: s_and_b32 s1, ttmp7, 0xffff
10 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
11 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v1, s1
12 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v2, s2
13 ; GFX9-SDAG-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
14 ; GFX9-SDAG-NEXT: s_endpgm
16 ; GFX9-GISEL-LABEL: _amdgpu_cs_main:
17 ; GFX9-GISEL: ; %bb.0: ; %.entry
18 ; GFX9-GISEL-NEXT: s_mov_b32 s0, ttmp9
19 ; GFX9-GISEL-NEXT: s_and_b32 s1, ttmp7, 0xffff
20 ; GFX9-GISEL-NEXT: s_lshr_b32 s2, ttmp7, 16
21 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, s0
22 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v1, s1
23 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v2, s2
24 ; GFX9-GISEL-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
25 ; GFX9-GISEL-NEXT: s_endpgm
27 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
28 %idy = call i32 @llvm.amdgcn.workgroup.id.y()
29 %idz = call i32 @llvm.amdgcn.workgroup.id.z()
30 %ielemx = insertelement <3 x i32> undef, i32 %idx, i64 0
31 %ielemy = insertelement <3 x i32> %ielemx, i32 %idy, i64 1
32 %ielemz = insertelement <3 x i32> %ielemy, i32 %idz, i64 2
33 call void @llvm.amdgcn.raw.ptr.buffer.store.v3i32(<3 x i32> %ielemz, ptr addrspace(8) undef, i32 0, i32 0, i32 0)
37 define amdgpu_cs void @caller() {
38 ; GFX9-SDAG-LABEL: caller:
40 ; GFX9-SDAG-NEXT: s_getpc_b64 s[8:9]
41 ; GFX9-SDAG-NEXT: s_mov_b32 s8, s0
42 ; GFX9-SDAG-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
43 ; GFX9-SDAG-NEXT: s_mov_b32 s5, callee@abs32@hi
44 ; GFX9-SDAG-NEXT: s_mov_b32 s4, callee@abs32@lo
45 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
46 ; GFX9-SDAG-NEXT: s_mov_b32 s32, 0
47 ; GFX9-SDAG-NEXT: s_waitcnt lgkmcnt(0)
48 ; GFX9-SDAG-NEXT: s_add_u32 s8, s8, s0
49 ; GFX9-SDAG-NEXT: s_addc_u32 s9, s9, 0
50 ; GFX9-SDAG-NEXT: s_mov_b64 s[0:1], s[8:9]
51 ; GFX9-SDAG-NEXT: s_mov_b64 s[2:3], s[10:11]
52 ; GFX9-SDAG-NEXT: s_swappc_b64 s[30:31], s[4:5]
53 ; GFX9-SDAG-NEXT: s_endpgm
55 ; GFX9-GISEL-LABEL: caller:
56 ; GFX9-GISEL: ; %bb.0:
57 ; GFX9-GISEL-NEXT: s_getpc_b64 s[8:9]
58 ; GFX9-GISEL-NEXT: s_mov_b32 s8, s0
59 ; GFX9-GISEL-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
60 ; GFX9-GISEL-NEXT: s_mov_b32 s4, callee@abs32@lo
61 ; GFX9-GISEL-NEXT: s_mov_b32 s5, callee@abs32@hi
62 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, ttmp9
63 ; GFX9-GISEL-NEXT: s_mov_b32 s32, 0
64 ; GFX9-GISEL-NEXT: s_waitcnt lgkmcnt(0)
65 ; GFX9-GISEL-NEXT: s_add_u32 s8, s8, s0
66 ; GFX9-GISEL-NEXT: s_addc_u32 s9, s9, 0
67 ; GFX9-GISEL-NEXT: s_mov_b64 s[0:1], s[8:9]
68 ; GFX9-GISEL-NEXT: s_mov_b64 s[2:3], s[10:11]
69 ; GFX9-GISEL-NEXT: s_swappc_b64 s[30:31], s[4:5]
70 ; GFX9-GISEL-NEXT: s_endpgm
71 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
72 call amdgpu_gfx void @callee(i32 %idx)
76 declare amdgpu_gfx void @callee(i32)
78 declare i32 @llvm.amdgcn.workgroup.id.x()
79 declare i32 @llvm.amdgcn.workgroup.id.y()
80 declare i32 @llvm.amdgcn.workgroup.id.z()
81 declare void @llvm.amdgcn.raw.ptr.buffer.store.v3i32(<3 x i32>, ptr addrspace(8), i32, i32, i32 immarg)