xref: /llvm-project/llvm/test/CodeGen/AMDGPU/stacksave_stackrestore.ll (revision 11b040192640ef3b1f481124c440f464ed6ec86a)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1030 < %s | FileCheck -check-prefixes=GCN,WAVE32,WAVE32-OPT %s
3; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1030 -mattr=+wavefrontsize64 < %s | FileCheck -check-prefixes=GCN,WAVE64,WAVE64-OPT %s
4
5; RUN: llc -O0 -mtriple=amdgcn-amd-amdpal -mcpu=gfx1030 < %s | FileCheck -check-prefixes=GCN,WAVE32,WAVE32-O0 %s
6; RUN: llc -O0 -mtriple=amdgcn-amd-amdpal -mcpu=gfx1030 -mattr=+wavefrontsize64 < %s | FileCheck -check-prefixes=GCN,WAVE64,WAVE64-O0 %s
7; RUN: llc -O0 -mtriple=amdgcn-amd-amdpal -mcpu=gfx1030 -amdgpu-prealloc-sgpr-spill-vgprs=1 < %s | FileCheck -check-prefixes=GCN,WAVE32,WAVE32-WWM-PREALLOC %s
8
9declare ptr addrspace(5) @llvm.stacksave.p5()
10declare void @llvm.stackrestore.p5(ptr addrspace(5))
11
12define hidden void @stack_passed_argument([32 x i32], i32) {
13; GCN-LABEL: stack_passed_argument:
14; GCN:       ; %bb.0:
15; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
16; GCN-NEXT:    s_setpc_b64 s[30:31]
17  ret void
18}
19
20define void @func_store_stacksave() {
21; WAVE32-OPT-LABEL: func_store_stacksave:
22; WAVE32-OPT:       ; %bb.0:
23; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
24; WAVE32-OPT-NEXT:    s_lshr_b32 s4, s32, 5
25; WAVE32-OPT-NEXT:    ;;#ASMSTART
26; WAVE32-OPT-NEXT:    ; use s4
27; WAVE32-OPT-NEXT:    ;;#ASMEND
28; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
29;
30; WAVE64-OPT-LABEL: func_store_stacksave:
31; WAVE64-OPT:       ; %bb.0:
32; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
33; WAVE64-OPT-NEXT:    s_lshr_b32 s4, s32, 6
34; WAVE64-OPT-NEXT:    ;;#ASMSTART
35; WAVE64-OPT-NEXT:    ; use s4
36; WAVE64-OPT-NEXT:    ;;#ASMEND
37; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
38;
39; WAVE32-O0-LABEL: func_store_stacksave:
40; WAVE32-O0:       ; %bb.0:
41; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
42; WAVE32-O0-NEXT:    s_mov_b32 s4, s32
43; WAVE32-O0-NEXT:    s_lshr_b32 s4, s4, 5
44; WAVE32-O0-NEXT:    ;;#ASMSTART
45; WAVE32-O0-NEXT:    ; use s4
46; WAVE32-O0-NEXT:    ;;#ASMEND
47; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
48;
49; WAVE64-O0-LABEL: func_store_stacksave:
50; WAVE64-O0:       ; %bb.0:
51; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
52; WAVE64-O0-NEXT:    s_mov_b32 s4, s32
53; WAVE64-O0-NEXT:    s_lshr_b32 s4, s4, 6
54; WAVE64-O0-NEXT:    ;;#ASMSTART
55; WAVE64-O0-NEXT:    ; use s4
56; WAVE64-O0-NEXT:    ;;#ASMEND
57; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
58;
59; WAVE32-WWM-PREALLOC-LABEL: func_store_stacksave:
60; WAVE32-WWM-PREALLOC:       ; %bb.0:
61; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
62; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s4, s32
63; WAVE32-WWM-PREALLOC-NEXT:    s_lshr_b32 s4, s4, 5
64; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMSTART
65; WAVE32-WWM-PREALLOC-NEXT:    ; use s4
66; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMEND
67; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
68  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
69  call void asm sideeffect "; use $0", "s"(ptr addrspace(5) %stacksave)
70  ret void
71}
72
73define amdgpu_kernel void @kernel_store_stacksave() {
74; WAVE32-OPT-LABEL: kernel_store_stacksave:
75; WAVE32-OPT:       ; %bb.0:
76; WAVE32-OPT-NEXT:    s_lshr_b32 s0, s32, 5
77; WAVE32-OPT-NEXT:    ;;#ASMSTART
78; WAVE32-OPT-NEXT:    ; use s0
79; WAVE32-OPT-NEXT:    ;;#ASMEND
80; WAVE32-OPT-NEXT:    s_endpgm
81;
82; WAVE64-OPT-LABEL: kernel_store_stacksave:
83; WAVE64-OPT:       ; %bb.0:
84; WAVE64-OPT-NEXT:    s_lshr_b32 s0, s32, 6
85; WAVE64-OPT-NEXT:    ;;#ASMSTART
86; WAVE64-OPT-NEXT:    ; use s0
87; WAVE64-OPT-NEXT:    ;;#ASMEND
88; WAVE64-OPT-NEXT:    s_endpgm
89;
90; WAVE32-O0-LABEL: kernel_store_stacksave:
91; WAVE32-O0:       ; %bb.0:
92; WAVE32-O0-NEXT:    s_mov_b32 s0, s32
93; WAVE32-O0-NEXT:    s_lshr_b32 s0, s0, 5
94; WAVE32-O0-NEXT:    ;;#ASMSTART
95; WAVE32-O0-NEXT:    ; use s0
96; WAVE32-O0-NEXT:    ;;#ASMEND
97; WAVE32-O0-NEXT:    s_endpgm
98;
99; WAVE64-O0-LABEL: kernel_store_stacksave:
100; WAVE64-O0:       ; %bb.0:
101; WAVE64-O0-NEXT:    s_mov_b32 s0, s32
102; WAVE64-O0-NEXT:    s_lshr_b32 s0, s0, 6
103; WAVE64-O0-NEXT:    ;;#ASMSTART
104; WAVE64-O0-NEXT:    ; use s0
105; WAVE64-O0-NEXT:    ;;#ASMEND
106; WAVE64-O0-NEXT:    s_endpgm
107;
108; WAVE32-WWM-PREALLOC-LABEL: kernel_store_stacksave:
109; WAVE32-WWM-PREALLOC:       ; %bb.0:
110; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s0, s32
111; WAVE32-WWM-PREALLOC-NEXT:    s_lshr_b32 s0, s0, 5
112; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMSTART
113; WAVE32-WWM-PREALLOC-NEXT:    ; use s0
114; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMEND
115; WAVE32-WWM-PREALLOC-NEXT:    s_endpgm
116  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
117  call void asm sideeffect "; use $0", "s"(ptr addrspace(5) %stacksave)
118  ret void
119}
120
121define amdgpu_kernel void @kernel_store_stacksave_nocall() {
122; WAVE32-OPT-LABEL: kernel_store_stacksave_nocall:
123; WAVE32-OPT:       ; %bb.0:
124; WAVE32-OPT-NEXT:    s_getpc_b64 s[12:13]
125; WAVE32-OPT-NEXT:    s_mov_b32 s12, s0
126; WAVE32-OPT-NEXT:    v_mov_b32_e32 v0, 0
127; WAVE32-OPT-NEXT:    s_load_dwordx4 s[12:15], s[12:13], 0x0
128; WAVE32-OPT-NEXT:    s_waitcnt lgkmcnt(0)
129; WAVE32-OPT-NEXT:    s_bitset0_b32 s15, 21
130; WAVE32-OPT-NEXT:    s_add_u32 s12, s12, s11
131; WAVE32-OPT-NEXT:    s_addc_u32 s13, s13, 0
132; WAVE32-OPT-NEXT:    s_lshr_b32 s0, s32, 5
133; WAVE32-OPT-NEXT:    v_mov_b32_e32 v1, s0
134; WAVE32-OPT-NEXT:    buffer_store_dword v0, v1, s[12:15], 0 offen
135; WAVE32-OPT-NEXT:    s_endpgm
136;
137; WAVE64-OPT-LABEL: kernel_store_stacksave_nocall:
138; WAVE64-OPT:       ; %bb.0:
139; WAVE64-OPT-NEXT:    s_getpc_b64 s[12:13]
140; WAVE64-OPT-NEXT:    s_mov_b32 s12, s0
141; WAVE64-OPT-NEXT:    v_mov_b32_e32 v0, 0
142; WAVE64-OPT-NEXT:    s_load_dwordx4 s[12:15], s[12:13], 0x0
143; WAVE64-OPT-NEXT:    s_waitcnt lgkmcnt(0)
144; WAVE64-OPT-NEXT:    s_add_u32 s12, s12, s11
145; WAVE64-OPT-NEXT:    s_addc_u32 s13, s13, 0
146; WAVE64-OPT-NEXT:    s_lshr_b32 s0, s32, 6
147; WAVE64-OPT-NEXT:    v_mov_b32_e32 v1, s0
148; WAVE64-OPT-NEXT:    buffer_store_dword v0, v1, s[12:15], 0 offen
149; WAVE64-OPT-NEXT:    s_endpgm
150;
151; WAVE32-O0-LABEL: kernel_store_stacksave_nocall:
152; WAVE32-O0:       ; %bb.0:
153; WAVE32-O0-NEXT:    s_getpc_b64 s[12:13]
154; WAVE32-O0-NEXT:    s_mov_b32 s12, s0
155; WAVE32-O0-NEXT:    s_load_dwordx4 s[12:15], s[12:13], 0x0
156; WAVE32-O0-NEXT:    s_waitcnt lgkmcnt(0)
157; WAVE32-O0-NEXT:    s_bitset0_b32 s15, 21
158; WAVE32-O0-NEXT:    s_add_u32 s12, s12, s11
159; WAVE32-O0-NEXT:    s_addc_u32 s13, s13, 0
160; WAVE32-O0-NEXT:    s_mov_b32 s0, s32
161; WAVE32-O0-NEXT:    s_lshr_b32 s0, s0, 5
162; WAVE32-O0-NEXT:    v_mov_b32_e32 v0, 0
163; WAVE32-O0-NEXT:    v_mov_b32_e32 v1, s0
164; WAVE32-O0-NEXT:    buffer_store_dword v0, v1, s[12:15], 0 offen
165; WAVE32-O0-NEXT:    s_endpgm
166;
167; WAVE64-O0-LABEL: kernel_store_stacksave_nocall:
168; WAVE64-O0:       ; %bb.0:
169; WAVE64-O0-NEXT:    s_getpc_b64 s[12:13]
170; WAVE64-O0-NEXT:    s_mov_b32 s12, s0
171; WAVE64-O0-NEXT:    s_load_dwordx4 s[12:15], s[12:13], 0x0
172; WAVE64-O0-NEXT:    s_waitcnt lgkmcnt(0)
173; WAVE64-O0-NEXT:    s_add_u32 s12, s12, s11
174; WAVE64-O0-NEXT:    s_addc_u32 s13, s13, 0
175; WAVE64-O0-NEXT:    s_mov_b32 s0, s32
176; WAVE64-O0-NEXT:    s_lshr_b32 s0, s0, 6
177; WAVE64-O0-NEXT:    v_mov_b32_e32 v0, 0
178; WAVE64-O0-NEXT:    v_mov_b32_e32 v1, s0
179; WAVE64-O0-NEXT:    buffer_store_dword v0, v1, s[12:15], 0 offen
180; WAVE64-O0-NEXT:    s_endpgm
181;
182; WAVE32-WWM-PREALLOC-LABEL: kernel_store_stacksave_nocall:
183; WAVE32-WWM-PREALLOC:       ; %bb.0:
184; WAVE32-WWM-PREALLOC-NEXT:    s_getpc_b64 s[12:13]
185; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s12, s0
186; WAVE32-WWM-PREALLOC-NEXT:    s_load_dwordx4 s[12:15], s[12:13], 0x0
187; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt lgkmcnt(0)
188; WAVE32-WWM-PREALLOC-NEXT:    s_bitset0_b32 s15, 21
189; WAVE32-WWM-PREALLOC-NEXT:    s_add_u32 s12, s12, s11
190; WAVE32-WWM-PREALLOC-NEXT:    s_addc_u32 s13, s13, 0
191; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s0, s32
192; WAVE32-WWM-PREALLOC-NEXT:    s_lshr_b32 s0, s0, 5
193; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v0, 0
194; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v1, s0
195; WAVE32-WWM-PREALLOC-NEXT:    buffer_store_dword v0, v1, s[12:15], 0 offen
196; WAVE32-WWM-PREALLOC-NEXT:    s_endpgm
197  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
198  store i32 0, ptr addrspace(5) %stacksave
199  ret void
200}
201
202define void @func_stacksave_nonentry_block(i1 %cond) {
203; WAVE32-OPT-LABEL: func_stacksave_nonentry_block:
204; WAVE32-OPT:       ; %bb.0: ; %bb0
205; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
206; WAVE32-OPT-NEXT:    v_and_b32_e32 v0, 1, v0
207; WAVE32-OPT-NEXT:    s_mov_b32 s4, exec_lo
208; WAVE32-OPT-NEXT:    v_cmpx_eq_u32_e32 1, v0
209; WAVE32-OPT-NEXT:    s_cbranch_execz .LBB4_2
210; WAVE32-OPT-NEXT:  ; %bb.1: ; %bb1
211; WAVE32-OPT-NEXT:    s_lshr_b32 s5, s32, 5
212; WAVE32-OPT-NEXT:    ;;#ASMSTART
213; WAVE32-OPT-NEXT:    ; use s5
214; WAVE32-OPT-NEXT:    ;;#ASMEND
215; WAVE32-OPT-NEXT:  .LBB4_2: ; %bb2
216; WAVE32-OPT-NEXT:    s_or_b32 exec_lo, exec_lo, s4
217; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
218;
219; WAVE64-OPT-LABEL: func_stacksave_nonentry_block:
220; WAVE64-OPT:       ; %bb.0: ; %bb0
221; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
222; WAVE64-OPT-NEXT:    v_and_b32_e32 v0, 1, v0
223; WAVE64-OPT-NEXT:    s_mov_b64 s[4:5], exec
224; WAVE64-OPT-NEXT:    v_cmpx_eq_u32_e32 1, v0
225; WAVE64-OPT-NEXT:    s_cbranch_execz .LBB4_2
226; WAVE64-OPT-NEXT:  ; %bb.1: ; %bb1
227; WAVE64-OPT-NEXT:    s_lshr_b32 s6, s32, 6
228; WAVE64-OPT-NEXT:    ;;#ASMSTART
229; WAVE64-OPT-NEXT:    ; use s6
230; WAVE64-OPT-NEXT:    ;;#ASMEND
231; WAVE64-OPT-NEXT:  .LBB4_2: ; %bb2
232; WAVE64-OPT-NEXT:    s_or_b64 exec, exec, s[4:5]
233; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
234;
235; WAVE32-O0-LABEL: func_stacksave_nonentry_block:
236; WAVE32-O0:       ; %bb.0: ; %bb0
237; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
238; WAVE32-O0-NEXT:    s_xor_saveexec_b32 s4, -1
239; WAVE32-O0-NEXT:    buffer_store_dword v1, off, s[0:3], s32 offset:4 ; 4-byte Folded Spill
240; WAVE32-O0-NEXT:    s_mov_b32 exec_lo, s4
241; WAVE32-O0-NEXT:    v_and_b32_e64 v0, 1, v0
242; WAVE32-O0-NEXT:    v_cmp_eq_u32_e64 s5, v0, 1
243; WAVE32-O0-NEXT:    s_mov_b32 s4, exec_lo
244; WAVE32-O0-NEXT:    ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
245; WAVE32-O0-NEXT:    v_writelane_b32 v1, s4, 0
246; WAVE32-O0-NEXT:    s_or_saveexec_b32 s7, -1
247; WAVE32-O0-NEXT:    buffer_store_dword v1, off, s[0:3], s32 ; 4-byte Folded Spill
248; WAVE32-O0-NEXT:    s_mov_b32 exec_lo, s7
249; WAVE32-O0-NEXT:    s_and_b32 s4, s4, s5
250; WAVE32-O0-NEXT:    s_mov_b32 exec_lo, s4
251; WAVE32-O0-NEXT:    s_cbranch_execz .LBB4_2
252; WAVE32-O0-NEXT:  ; %bb.1: ; %bb1
253; WAVE32-O0-NEXT:    s_mov_b32 s4, s32
254; WAVE32-O0-NEXT:    s_lshr_b32 s4, s4, 5
255; WAVE32-O0-NEXT:    ;;#ASMSTART
256; WAVE32-O0-NEXT:    ; use s4
257; WAVE32-O0-NEXT:    ;;#ASMEND
258; WAVE32-O0-NEXT:  .LBB4_2: ; %bb2
259; WAVE32-O0-NEXT:    s_or_saveexec_b32 s7, -1
260; WAVE32-O0-NEXT:    buffer_load_dword v1, off, s[0:3], s32 ; 4-byte Folded Reload
261; WAVE32-O0-NEXT:    s_mov_b32 exec_lo, s7
262; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0)
263; WAVE32-O0-NEXT:    v_readlane_b32 s4, v1, 0
264; WAVE32-O0-NEXT:    s_or_b32 exec_lo, exec_lo, s4
265; WAVE32-O0-NEXT:    s_xor_saveexec_b32 s4, -1
266; WAVE32-O0-NEXT:    buffer_load_dword v1, off, s[0:3], s32 offset:4 ; 4-byte Folded Reload
267; WAVE32-O0-NEXT:    s_mov_b32 exec_lo, s4
268; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0)
269; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
270;
271; WAVE64-O0-LABEL: func_stacksave_nonentry_block:
272; WAVE64-O0:       ; %bb.0: ; %bb0
273; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
274; WAVE64-O0-NEXT:    s_xor_saveexec_b64 s[4:5], -1
275; WAVE64-O0-NEXT:    buffer_store_dword v1, off, s[0:3], s32 offset:4 ; 4-byte Folded Spill
276; WAVE64-O0-NEXT:    s_mov_b64 exec, s[4:5]
277; WAVE64-O0-NEXT:    v_and_b32_e64 v0, 1, v0
278; WAVE64-O0-NEXT:    v_cmp_eq_u32_e64 s[6:7], v0, 1
279; WAVE64-O0-NEXT:    s_mov_b64 s[4:5], exec
280; WAVE64-O0-NEXT:    ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
281; WAVE64-O0-NEXT:    v_writelane_b32 v1, s4, 0
282; WAVE64-O0-NEXT:    v_writelane_b32 v1, s5, 1
283; WAVE64-O0-NEXT:    s_or_saveexec_b64 s[10:11], -1
284; WAVE64-O0-NEXT:    buffer_store_dword v1, off, s[0:3], s32 ; 4-byte Folded Spill
285; WAVE64-O0-NEXT:    s_mov_b64 exec, s[10:11]
286; WAVE64-O0-NEXT:    s_and_b64 s[4:5], s[4:5], s[6:7]
287; WAVE64-O0-NEXT:    s_mov_b64 exec, s[4:5]
288; WAVE64-O0-NEXT:    s_cbranch_execz .LBB4_2
289; WAVE64-O0-NEXT:  ; %bb.1: ; %bb1
290; WAVE64-O0-NEXT:    s_mov_b32 s4, s32
291; WAVE64-O0-NEXT:    s_lshr_b32 s4, s4, 6
292; WAVE64-O0-NEXT:    ;;#ASMSTART
293; WAVE64-O0-NEXT:    ; use s4
294; WAVE64-O0-NEXT:    ;;#ASMEND
295; WAVE64-O0-NEXT:  .LBB4_2: ; %bb2
296; WAVE64-O0-NEXT:    s_or_saveexec_b64 s[10:11], -1
297; WAVE64-O0-NEXT:    buffer_load_dword v1, off, s[0:3], s32 ; 4-byte Folded Reload
298; WAVE64-O0-NEXT:    s_mov_b64 exec, s[10:11]
299; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0)
300; WAVE64-O0-NEXT:    v_readlane_b32 s4, v1, 0
301; WAVE64-O0-NEXT:    v_readlane_b32 s5, v1, 1
302; WAVE64-O0-NEXT:    s_or_b64 exec, exec, s[4:5]
303; WAVE64-O0-NEXT:    s_xor_saveexec_b64 s[4:5], -1
304; WAVE64-O0-NEXT:    buffer_load_dword v1, off, s[0:3], s32 offset:4 ; 4-byte Folded Reload
305; WAVE64-O0-NEXT:    s_mov_b64 exec, s[4:5]
306; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0)
307; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
308;
309; WAVE32-WWM-PREALLOC-LABEL: func_stacksave_nonentry_block:
310; WAVE32-WWM-PREALLOC:       ; %bb.0: ; %bb0
311; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
312; WAVE32-WWM-PREALLOC-NEXT:    s_xor_saveexec_b32 s4, -1
313; WAVE32-WWM-PREALLOC-NEXT:    buffer_store_dword v1, off, s[0:3], s32 ; 4-byte Folded Spill
314; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 exec_lo, s4
315; WAVE32-WWM-PREALLOC-NEXT:    v_and_b32_e64 v0, 1, v0
316; WAVE32-WWM-PREALLOC-NEXT:    v_cmp_eq_u32_e64 s5, v0, 1
317; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s4, exec_lo
318; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
319; WAVE32-WWM-PREALLOC-NEXT:    v_writelane_b32 v1, s4, 0
320; WAVE32-WWM-PREALLOC-NEXT:    s_and_b32 s4, s4, s5
321; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 exec_lo, s4
322; WAVE32-WWM-PREALLOC-NEXT:    s_cbranch_execz .LBB4_2
323; WAVE32-WWM-PREALLOC-NEXT:  ; %bb.1: ; %bb1
324; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s4, s32
325; WAVE32-WWM-PREALLOC-NEXT:    s_lshr_b32 s4, s4, 5
326; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMSTART
327; WAVE32-WWM-PREALLOC-NEXT:    ; use s4
328; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMEND
329; WAVE32-WWM-PREALLOC-NEXT:  .LBB4_2: ; %bb2
330; WAVE32-WWM-PREALLOC-NEXT:    v_readlane_b32 s4, v1, 0
331; WAVE32-WWM-PREALLOC-NEXT:    s_or_b32 exec_lo, exec_lo, s4
332; WAVE32-WWM-PREALLOC-NEXT:    s_xor_saveexec_b32 s4, -1
333; WAVE32-WWM-PREALLOC-NEXT:    buffer_load_dword v1, off, s[0:3], s32 ; 4-byte Folded Reload
334; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 exec_lo, s4
335; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0)
336; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
337bb0:
338  br i1 %cond, label %bb1, label %bb2
339
340bb1:
341  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
342  call void asm sideeffect "; use $0", "s"(ptr addrspace(5) %stacksave)
343  br label %bb2
344
345bb2:
346  ret void
347}
348
349define void @func_stackrestore_poison() {
350; WAVE32-OPT-LABEL: func_stackrestore_poison:
351; WAVE32-OPT:       ; %bb.0:
352; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
353; WAVE32-OPT-NEXT:    s_lshl_b32 s32, s4, 5
354; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
355;
356; WAVE64-OPT-LABEL: func_stackrestore_poison:
357; WAVE64-OPT:       ; %bb.0:
358; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
359; WAVE64-OPT-NEXT:    s_lshl_b32 s32, s4, 6
360; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
361;
362; WAVE32-O0-LABEL: func_stackrestore_poison:
363; WAVE32-O0:       ; %bb.0:
364; WAVE32-O0-NEXT:    ; implicit-def: $sgpr4
365; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
366; WAVE32-O0-NEXT:    s_lshl_b32 s4, s4, 5
367; WAVE32-O0-NEXT:    s_mov_b32 s32, s4
368; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
369;
370; WAVE64-O0-LABEL: func_stackrestore_poison:
371; WAVE64-O0:       ; %bb.0:
372; WAVE64-O0-NEXT:    ; implicit-def: $sgpr4
373; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
374; WAVE64-O0-NEXT:    s_lshl_b32 s4, s4, 6
375; WAVE64-O0-NEXT:    s_mov_b32 s32, s4
376; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
377;
378; WAVE32-WWM-PREALLOC-LABEL: func_stackrestore_poison:
379; WAVE32-WWM-PREALLOC:       ; %bb.0:
380; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr4
381; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
382; WAVE32-WWM-PREALLOC-NEXT:    s_lshl_b32 s4, s4, 5
383; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s4
384; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
385  call void @llvm.stackrestore.p5(ptr addrspace(5) poison)
386  ret void
387}
388
389define void @func_stackrestore_null() {
390; WAVE32-OPT-LABEL: func_stackrestore_null:
391; WAVE32-OPT:       ; %bb.0:
392; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
393; WAVE32-OPT-NEXT:    s_mov_b32 s32, 0
394; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
395;
396; WAVE64-OPT-LABEL: func_stackrestore_null:
397; WAVE64-OPT:       ; %bb.0:
398; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
399; WAVE64-OPT-NEXT:    s_mov_b32 s32, 0
400; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
401;
402; WAVE32-O0-LABEL: func_stackrestore_null:
403; WAVE32-O0:       ; %bb.0:
404; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
405; WAVE32-O0-NEXT:    s_mov_b32 s4, 0
406; WAVE32-O0-NEXT:    s_lshl_b32 s4, s4, 5
407; WAVE32-O0-NEXT:    s_mov_b32 s32, s4
408; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
409;
410; WAVE64-O0-LABEL: func_stackrestore_null:
411; WAVE64-O0:       ; %bb.0:
412; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
413; WAVE64-O0-NEXT:    s_mov_b32 s4, 0
414; WAVE64-O0-NEXT:    s_lshl_b32 s4, s4, 6
415; WAVE64-O0-NEXT:    s_mov_b32 s32, s4
416; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
417;
418; WAVE32-WWM-PREALLOC-LABEL: func_stackrestore_null:
419; WAVE32-WWM-PREALLOC:       ; %bb.0:
420; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
421; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s4, 0
422; WAVE32-WWM-PREALLOC-NEXT:    s_lshl_b32 s4, s4, 5
423; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s4
424; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
425  call void @llvm.stackrestore.p5(ptr addrspace(5) null)
426  ret void
427}
428
429define void @func_stackrestore_neg1() {
430; WAVE32-OPT-LABEL: func_stackrestore_neg1:
431; WAVE32-OPT:       ; %bb.0:
432; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
433; WAVE32-OPT-NEXT:    s_movk_i32 s32, 0xffe0
434; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
435;
436; WAVE64-OPT-LABEL: func_stackrestore_neg1:
437; WAVE64-OPT:       ; %bb.0:
438; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
439; WAVE64-OPT-NEXT:    s_movk_i32 s32, 0xffc0
440; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
441;
442; WAVE32-O0-LABEL: func_stackrestore_neg1:
443; WAVE32-O0:       ; %bb.0:
444; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
445; WAVE32-O0-NEXT:    s_mov_b32 s4, -1
446; WAVE32-O0-NEXT:    s_lshl_b32 s4, s4, 5
447; WAVE32-O0-NEXT:    s_mov_b32 s32, s4
448; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
449;
450; WAVE64-O0-LABEL: func_stackrestore_neg1:
451; WAVE64-O0:       ; %bb.0:
452; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
453; WAVE64-O0-NEXT:    s_mov_b32 s4, -1
454; WAVE64-O0-NEXT:    s_lshl_b32 s4, s4, 6
455; WAVE64-O0-NEXT:    s_mov_b32 s32, s4
456; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
457;
458; WAVE32-WWM-PREALLOC-LABEL: func_stackrestore_neg1:
459; WAVE32-WWM-PREALLOC:       ; %bb.0:
460; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
461; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s4, -1
462; WAVE32-WWM-PREALLOC-NEXT:    s_lshl_b32 s4, s4, 5
463; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s4
464; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
465  call void @llvm.stackrestore.p5(ptr addrspace(5) inttoptr (i32 -1 to ptr addrspace(5)))
466  ret void
467}
468
469define void @func_stackrestore_42() {
470; WAVE32-OPT-LABEL: func_stackrestore_42:
471; WAVE32-OPT:       ; %bb.0:
472; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
473; WAVE32-OPT-NEXT:    s_movk_i32 s32, 0x540
474; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
475;
476; WAVE64-OPT-LABEL: func_stackrestore_42:
477; WAVE64-OPT:       ; %bb.0:
478; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
479; WAVE64-OPT-NEXT:    s_movk_i32 s32, 0xa80
480; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
481;
482; WAVE32-O0-LABEL: func_stackrestore_42:
483; WAVE32-O0:       ; %bb.0:
484; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
485; WAVE32-O0-NEXT:    s_mov_b32 s4, 42
486; WAVE32-O0-NEXT:    s_lshl_b32 s4, s4, 5
487; WAVE32-O0-NEXT:    s_mov_b32 s32, s4
488; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
489;
490; WAVE64-O0-LABEL: func_stackrestore_42:
491; WAVE64-O0:       ; %bb.0:
492; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
493; WAVE64-O0-NEXT:    s_mov_b32 s4, 42
494; WAVE64-O0-NEXT:    s_lshl_b32 s4, s4, 6
495; WAVE64-O0-NEXT:    s_mov_b32 s32, s4
496; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
497;
498; WAVE32-WWM-PREALLOC-LABEL: func_stackrestore_42:
499; WAVE32-WWM-PREALLOC:       ; %bb.0:
500; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
501; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s4, 42
502; WAVE32-WWM-PREALLOC-NEXT:    s_lshl_b32 s4, s4, 5
503; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s4
504; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
505  call void @llvm.stackrestore.p5(ptr addrspace(5) inttoptr (i32 42 to ptr addrspace(5)))
506  ret void
507}
508
509define void @func_stacksave_stackrestore() {
510; WAVE32-OPT-LABEL: func_stacksave_stackrestore:
511; WAVE32-OPT:       ; %bb.0:
512; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
513; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
514;
515; WAVE64-OPT-LABEL: func_stacksave_stackrestore:
516; WAVE64-OPT:       ; %bb.0:
517; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
518; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
519;
520; WAVE32-O0-LABEL: func_stacksave_stackrestore:
521; WAVE32-O0:       ; %bb.0:
522; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
523; WAVE32-O0-NEXT:    s_mov_b32 s4, s32
524; WAVE32-O0-NEXT:    s_mov_b32 s32, s4
525; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
526;
527; WAVE64-O0-LABEL: func_stacksave_stackrestore:
528; WAVE64-O0:       ; %bb.0:
529; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
530; WAVE64-O0-NEXT:    s_mov_b32 s4, s32
531; WAVE64-O0-NEXT:    s_mov_b32 s32, s4
532; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
533;
534; WAVE32-WWM-PREALLOC-LABEL: func_stacksave_stackrestore:
535; WAVE32-WWM-PREALLOC:       ; %bb.0:
536; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
537; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s4, s32
538; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s4
539; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
540  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
541  call void @llvm.stackrestore.p5(ptr addrspace(5) %stacksave)
542  ret void
543}
544
545define void @func_stacksave_stackrestore_use() {
546; WAVE32-OPT-LABEL: func_stacksave_stackrestore_use:
547; WAVE32-OPT:       ; %bb.0:
548; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
549; WAVE32-OPT-NEXT:    s_lshr_b32 s4, s32, 5
550; WAVE32-OPT-NEXT:    ;;#ASMSTART
551; WAVE32-OPT-NEXT:    ; use s4
552; WAVE32-OPT-NEXT:    ;;#ASMEND
553; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
554;
555; WAVE64-OPT-LABEL: func_stacksave_stackrestore_use:
556; WAVE64-OPT:       ; %bb.0:
557; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
558; WAVE64-OPT-NEXT:    s_lshr_b32 s4, s32, 6
559; WAVE64-OPT-NEXT:    ;;#ASMSTART
560; WAVE64-OPT-NEXT:    ; use s4
561; WAVE64-OPT-NEXT:    ;;#ASMEND
562; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
563;
564; WAVE32-O0-LABEL: func_stacksave_stackrestore_use:
565; WAVE32-O0:       ; %bb.0:
566; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
567; WAVE32-O0-NEXT:    s_mov_b32 s4, s32
568; WAVE32-O0-NEXT:    s_lshr_b32 s5, s4, 5
569; WAVE32-O0-NEXT:    ;;#ASMSTART
570; WAVE32-O0-NEXT:    ; use s5
571; WAVE32-O0-NEXT:    ;;#ASMEND
572; WAVE32-O0-NEXT:    s_mov_b32 s32, s4
573; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
574;
575; WAVE64-O0-LABEL: func_stacksave_stackrestore_use:
576; WAVE64-O0:       ; %bb.0:
577; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
578; WAVE64-O0-NEXT:    s_mov_b32 s4, s32
579; WAVE64-O0-NEXT:    s_lshr_b32 s5, s4, 6
580; WAVE64-O0-NEXT:    ;;#ASMSTART
581; WAVE64-O0-NEXT:    ; use s5
582; WAVE64-O0-NEXT:    ;;#ASMEND
583; WAVE64-O0-NEXT:    s_mov_b32 s32, s4
584; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
585;
586; WAVE32-WWM-PREALLOC-LABEL: func_stacksave_stackrestore_use:
587; WAVE32-WWM-PREALLOC:       ; %bb.0:
588; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
589; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s4, s32
590; WAVE32-WWM-PREALLOC-NEXT:    s_lshr_b32 s5, s4, 5
591; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMSTART
592; WAVE32-WWM-PREALLOC-NEXT:    ; use s5
593; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMEND
594; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s4
595; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
596  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
597  call void asm sideeffect "; use $0", "s"(ptr addrspace(5) %stacksave)
598  call void @llvm.stackrestore.p5(ptr addrspace(5) %stacksave)
599  ret void
600}
601
602define amdgpu_kernel void @kernel_stacksave_stackrestore_use() {
603; WAVE32-OPT-LABEL: kernel_stacksave_stackrestore_use:
604; WAVE32-OPT:       ; %bb.0:
605; WAVE32-OPT-NEXT:    s_lshr_b32 s0, s32, 5
606; WAVE32-OPT-NEXT:    ;;#ASMSTART
607; WAVE32-OPT-NEXT:    ; use s0
608; WAVE32-OPT-NEXT:    ;;#ASMEND
609; WAVE32-OPT-NEXT:    s_endpgm
610;
611; WAVE64-OPT-LABEL: kernel_stacksave_stackrestore_use:
612; WAVE64-OPT:       ; %bb.0:
613; WAVE64-OPT-NEXT:    s_lshr_b32 s0, s32, 6
614; WAVE64-OPT-NEXT:    ;;#ASMSTART
615; WAVE64-OPT-NEXT:    ; use s0
616; WAVE64-OPT-NEXT:    ;;#ASMEND
617; WAVE64-OPT-NEXT:    s_endpgm
618;
619; WAVE32-O0-LABEL: kernel_stacksave_stackrestore_use:
620; WAVE32-O0:       ; %bb.0:
621; WAVE32-O0-NEXT:    s_mov_b32 s0, s32
622; WAVE32-O0-NEXT:    s_lshr_b32 s1, s0, 5
623; WAVE32-O0-NEXT:    ;;#ASMSTART
624; WAVE32-O0-NEXT:    ; use s1
625; WAVE32-O0-NEXT:    ;;#ASMEND
626; WAVE32-O0-NEXT:    s_mov_b32 s32, s0
627; WAVE32-O0-NEXT:    s_endpgm
628;
629; WAVE64-O0-LABEL: kernel_stacksave_stackrestore_use:
630; WAVE64-O0:       ; %bb.0:
631; WAVE64-O0-NEXT:    s_mov_b32 s0, s32
632; WAVE64-O0-NEXT:    s_lshr_b32 s1, s0, 6
633; WAVE64-O0-NEXT:    ;;#ASMSTART
634; WAVE64-O0-NEXT:    ; use s1
635; WAVE64-O0-NEXT:    ;;#ASMEND
636; WAVE64-O0-NEXT:    s_mov_b32 s32, s0
637; WAVE64-O0-NEXT:    s_endpgm
638;
639; WAVE32-WWM-PREALLOC-LABEL: kernel_stacksave_stackrestore_use:
640; WAVE32-WWM-PREALLOC:       ; %bb.0:
641; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s0, s32
642; WAVE32-WWM-PREALLOC-NEXT:    s_lshr_b32 s1, s0, 5
643; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMSTART
644; WAVE32-WWM-PREALLOC-NEXT:    ; use s1
645; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMEND
646; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s0
647; WAVE32-WWM-PREALLOC-NEXT:    s_endpgm
648  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
649  call void asm sideeffect "; use $0", "s"(ptr addrspace(5) %stacksave)
650  call void @llvm.stackrestore.p5(ptr addrspace(5) %stacksave)
651  ret void
652}
653
654define void @func_stacksave_stackrestore_voffset(i32 %offset) {
655; WAVE32-OPT-LABEL: func_stacksave_stackrestore_voffset:
656; WAVE32-OPT:       ; %bb.0:
657; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
658; WAVE32-OPT-NEXT:    s_lshr_b32 s4, s32, 5
659; WAVE32-OPT-NEXT:    v_add_nc_u32_e32 v0, s4, v0
660; WAVE32-OPT-NEXT:    v_readfirstlane_b32 s4, v0
661; WAVE32-OPT-NEXT:    s_lshl_b32 s32, s4, 5
662; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
663;
664; WAVE64-OPT-LABEL: func_stacksave_stackrestore_voffset:
665; WAVE64-OPT:       ; %bb.0:
666; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
667; WAVE64-OPT-NEXT:    s_lshr_b32 s4, s32, 6
668; WAVE64-OPT-NEXT:    v_add_nc_u32_e32 v0, s4, v0
669; WAVE64-OPT-NEXT:    v_readfirstlane_b32 s4, v0
670; WAVE64-OPT-NEXT:    s_lshl_b32 s32, s4, 6
671; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
672;
673; WAVE32-O0-LABEL: func_stacksave_stackrestore_voffset:
674; WAVE32-O0:       ; %bb.0:
675; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
676; WAVE32-O0-NEXT:    s_mov_b32 s4, s32
677; WAVE32-O0-NEXT:    s_lshr_b32 s4, s4, 5
678; WAVE32-O0-NEXT:    v_add_nc_u32_e64 v0, s4, v0
679; WAVE32-O0-NEXT:    v_readfirstlane_b32 s4, v0
680; WAVE32-O0-NEXT:    s_lshl_b32 s4, s4, 5
681; WAVE32-O0-NEXT:    s_mov_b32 s32, s4
682; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
683;
684; WAVE64-O0-LABEL: func_stacksave_stackrestore_voffset:
685; WAVE64-O0:       ; %bb.0:
686; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
687; WAVE64-O0-NEXT:    s_mov_b32 s4, s32
688; WAVE64-O0-NEXT:    s_lshr_b32 s4, s4, 6
689; WAVE64-O0-NEXT:    v_add_nc_u32_e64 v0, s4, v0
690; WAVE64-O0-NEXT:    v_readfirstlane_b32 s4, v0
691; WAVE64-O0-NEXT:    s_lshl_b32 s4, s4, 6
692; WAVE64-O0-NEXT:    s_mov_b32 s32, s4
693; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
694;
695; WAVE32-WWM-PREALLOC-LABEL: func_stacksave_stackrestore_voffset:
696; WAVE32-WWM-PREALLOC:       ; %bb.0:
697; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
698; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s4, s32
699; WAVE32-WWM-PREALLOC-NEXT:    s_lshr_b32 s4, s4, 5
700; WAVE32-WWM-PREALLOC-NEXT:    v_add_nc_u32_e64 v0, s4, v0
701; WAVE32-WWM-PREALLOC-NEXT:    v_readfirstlane_b32 s4, v0
702; WAVE32-WWM-PREALLOC-NEXT:    s_lshl_b32 s4, s4, 5
703; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s4
704; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
705  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
706  %gep = getelementptr i8, ptr addrspace(5) %stacksave, i32 %offset
707  call void @llvm.stackrestore.p5(ptr addrspace(5) %gep)
708  ret void
709}
710
711define void @func_stacksave_vgpr(ptr addrspace(5) %stack) {
712; WAVE32-OPT-LABEL: func_stacksave_vgpr:
713; WAVE32-OPT:       ; %bb.0:
714; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
715; WAVE32-OPT-NEXT:    v_readfirstlane_b32 s4, v0
716; WAVE32-OPT-NEXT:    s_lshl_b32 s32, s4, 5
717; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
718;
719; WAVE64-OPT-LABEL: func_stacksave_vgpr:
720; WAVE64-OPT:       ; %bb.0:
721; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
722; WAVE64-OPT-NEXT:    v_readfirstlane_b32 s4, v0
723; WAVE64-OPT-NEXT:    s_lshl_b32 s32, s4, 6
724; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
725;
726; WAVE32-O0-LABEL: func_stacksave_vgpr:
727; WAVE32-O0:       ; %bb.0:
728; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
729; WAVE32-O0-NEXT:    v_readfirstlane_b32 s4, v0
730; WAVE32-O0-NEXT:    s_lshl_b32 s4, s4, 5
731; WAVE32-O0-NEXT:    s_mov_b32 s32, s4
732; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
733;
734; WAVE64-O0-LABEL: func_stacksave_vgpr:
735; WAVE64-O0:       ; %bb.0:
736; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
737; WAVE64-O0-NEXT:    v_readfirstlane_b32 s4, v0
738; WAVE64-O0-NEXT:    s_lshl_b32 s4, s4, 6
739; WAVE64-O0-NEXT:    s_mov_b32 s32, s4
740; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
741;
742; WAVE32-WWM-PREALLOC-LABEL: func_stacksave_vgpr:
743; WAVE32-WWM-PREALLOC:       ; %bb.0:
744; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
745; WAVE32-WWM-PREALLOC-NEXT:    v_readfirstlane_b32 s4, v0
746; WAVE32-WWM-PREALLOC-NEXT:    s_lshl_b32 s4, s4, 5
747; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s4
748; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
749  call void @llvm.stackrestore.p5(ptr addrspace(5) %stack)
750  ret void
751}
752
753define amdgpu_gfx void @func_stacksave_sgpr(ptr addrspace(5) inreg %stack) {
754; WAVE32-OPT-LABEL: func_stacksave_sgpr:
755; WAVE32-OPT:       ; %bb.0:
756; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
757; WAVE32-OPT-NEXT:    s_lshl_b32 s32, s4, 5
758; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
759;
760; WAVE64-OPT-LABEL: func_stacksave_sgpr:
761; WAVE64-OPT:       ; %bb.0:
762; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
763; WAVE64-OPT-NEXT:    s_lshl_b32 s32, s4, 6
764; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
765;
766; WAVE32-O0-LABEL: func_stacksave_sgpr:
767; WAVE32-O0:       ; %bb.0:
768; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
769; WAVE32-O0-NEXT:    s_lshl_b32 s34, s4, 5
770; WAVE32-O0-NEXT:    s_mov_b32 s32, s34
771; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
772;
773; WAVE64-O0-LABEL: func_stacksave_sgpr:
774; WAVE64-O0:       ; %bb.0:
775; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
776; WAVE64-O0-NEXT:    s_lshl_b32 s34, s4, 6
777; WAVE64-O0-NEXT:    s_mov_b32 s32, s34
778; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
779;
780; WAVE32-WWM-PREALLOC-LABEL: func_stacksave_sgpr:
781; WAVE32-WWM-PREALLOC:       ; %bb.0:
782; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
783; WAVE32-WWM-PREALLOC-NEXT:    s_lshl_b32 s34, s4, 5
784; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s34
785; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
786  call void @llvm.stackrestore.p5(ptr addrspace(5) %stack)
787  ret void
788}
789
790define amdgpu_kernel void @kernel_stacksave_sgpr(ptr addrspace(5) %stack) {
791; WAVE32-OPT-LABEL: kernel_stacksave_sgpr:
792; WAVE32-OPT:       ; %bb.0:
793; WAVE32-OPT-NEXT:    s_load_dword s0, s[4:5], 0x0
794; WAVE32-OPT-NEXT:    s_waitcnt lgkmcnt(0)
795; WAVE32-OPT-NEXT:    ;;#ASMSTART
796; WAVE32-OPT-NEXT:    ; use s0
797; WAVE32-OPT-NEXT:    ;;#ASMEND
798; WAVE32-OPT-NEXT:    s_endpgm
799;
800; WAVE64-OPT-LABEL: kernel_stacksave_sgpr:
801; WAVE64-OPT:       ; %bb.0:
802; WAVE64-OPT-NEXT:    s_load_dword s0, s[4:5], 0x0
803; WAVE64-OPT-NEXT:    s_waitcnt lgkmcnt(0)
804; WAVE64-OPT-NEXT:    ;;#ASMSTART
805; WAVE64-OPT-NEXT:    ; use s0
806; WAVE64-OPT-NEXT:    ;;#ASMEND
807; WAVE64-OPT-NEXT:    s_endpgm
808;
809; WAVE32-O0-LABEL: kernel_stacksave_sgpr:
810; WAVE32-O0:       ; %bb.0:
811; WAVE32-O0-NEXT:    s_load_dword s0, s[4:5], 0x0
812; WAVE32-O0-NEXT:    s_waitcnt lgkmcnt(0)
813; WAVE32-O0-NEXT:    s_mov_b32 s1, s0
814; WAVE32-O0-NEXT:    ;;#ASMSTART
815; WAVE32-O0-NEXT:    ; use s1
816; WAVE32-O0-NEXT:    ;;#ASMEND
817; WAVE32-O0-NEXT:    s_lshl_b32 s0, s0, 5
818; WAVE32-O0-NEXT:    s_mov_b32 s32, s0
819; WAVE32-O0-NEXT:    s_endpgm
820;
821; WAVE64-O0-LABEL: kernel_stacksave_sgpr:
822; WAVE64-O0:       ; %bb.0:
823; WAVE64-O0-NEXT:    s_load_dword s0, s[4:5], 0x0
824; WAVE64-O0-NEXT:    s_waitcnt lgkmcnt(0)
825; WAVE64-O0-NEXT:    s_mov_b32 s1, s0
826; WAVE64-O0-NEXT:    ;;#ASMSTART
827; WAVE64-O0-NEXT:    ; use s1
828; WAVE64-O0-NEXT:    ;;#ASMEND
829; WAVE64-O0-NEXT:    s_lshl_b32 s0, s0, 6
830; WAVE64-O0-NEXT:    s_mov_b32 s32, s0
831; WAVE64-O0-NEXT:    s_endpgm
832;
833; WAVE32-WWM-PREALLOC-LABEL: kernel_stacksave_sgpr:
834; WAVE32-WWM-PREALLOC:       ; %bb.0:
835; WAVE32-WWM-PREALLOC-NEXT:    s_load_dword s0, s[4:5], 0x0
836; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt lgkmcnt(0)
837; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s1, s0
838; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMSTART
839; WAVE32-WWM-PREALLOC-NEXT:    ; use s1
840; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMEND
841; WAVE32-WWM-PREALLOC-NEXT:    s_lshl_b32 s0, s0, 5
842; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s0
843; WAVE32-WWM-PREALLOC-NEXT:    s_endpgm
844  call void asm sideeffect "; use $0", "s"(ptr addrspace(5) %stack)
845  call void @llvm.stackrestore.p5(ptr addrspace(5) %stack)
846  ret void
847}
848
849define amdgpu_kernel void @kernel_stacksave_stackrestore_call_with_stack_objects() {
850; WAVE32-OPT-LABEL: kernel_stacksave_stackrestore_call_with_stack_objects:
851; WAVE32-OPT:       ; %bb.0:
852; WAVE32-OPT-NEXT:    s_getpc_b64 s[20:21]
853; WAVE32-OPT-NEXT:    s_mov_b32 s20, s0
854; WAVE32-OPT-NEXT:    v_lshlrev_b32_e32 v2, 20, v2
855; WAVE32-OPT-NEXT:    s_load_dwordx4 s[20:23], s[20:21], 0x0
856; WAVE32-OPT-NEXT:    v_lshlrev_b32_e32 v1, 10, v1
857; WAVE32-OPT-NEXT:    s_movk_i32 s32, 0x1200
858; WAVE32-OPT-NEXT:    s_mov_b32 s13, s9
859; WAVE32-OPT-NEXT:    s_mov_b32 s12, s8
860; WAVE32-OPT-NEXT:    s_mov_b64 s[8:9], s[4:5]
861; WAVE32-OPT-NEXT:    s_mov_b32 s4, s32
862; WAVE32-OPT-NEXT:    v_mov_b32_e32 v3, 42
863; WAVE32-OPT-NEXT:    v_mov_b32_e32 v4, 17
864; WAVE32-OPT-NEXT:    v_or3_b32 v31, v0, v1, v2
865; WAVE32-OPT-NEXT:    s_mov_b32 s14, s10
866; WAVE32-OPT-NEXT:    s_mov_b32 s17, stack_passed_argument@abs32@hi
867; WAVE32-OPT-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
868; WAVE32-OPT-NEXT:    s_waitcnt lgkmcnt(0)
869; WAVE32-OPT-NEXT:    s_bitset0_b32 s23, 21
870; WAVE32-OPT-NEXT:    s_add_u32 s20, s20, s11
871; WAVE32-OPT-NEXT:    s_addc_u32 s21, s21, 0
872; WAVE32-OPT-NEXT:    s_mov_b64 s[10:11], s[6:7]
873; WAVE32-OPT-NEXT:    s_lshr_b32 s15, s4, 5
874; WAVE32-OPT-NEXT:    s_mov_b64 s[4:5], s[0:1]
875; WAVE32-OPT-NEXT:    s_mov_b64 s[6:7], s[2:3]
876; WAVE32-OPT-NEXT:    s_mov_b64 s[0:1], s[20:21]
877; WAVE32-OPT-NEXT:    s_mov_b64 s[2:3], s[22:23]
878; WAVE32-OPT-NEXT:    buffer_store_dword v3, off, s[20:23], 0
879; WAVE32-OPT-NEXT:    s_waitcnt_vscnt null, 0x0
880; WAVE32-OPT-NEXT:    buffer_store_dword v4, off, s[20:23], s32 offset:4
881; WAVE32-OPT-NEXT:    s_swappc_b64 s[30:31], s[16:17]
882; WAVE32-OPT-NEXT:    ;;#ASMSTART
883; WAVE32-OPT-NEXT:    ; use s15
884; WAVE32-OPT-NEXT:    ;;#ASMEND
885; WAVE32-OPT-NEXT:    s_endpgm
886;
887; WAVE64-OPT-LABEL: kernel_stacksave_stackrestore_call_with_stack_objects:
888; WAVE64-OPT:       ; %bb.0:
889; WAVE64-OPT-NEXT:    s_getpc_b64 s[20:21]
890; WAVE64-OPT-NEXT:    s_mov_b32 s20, s0
891; WAVE64-OPT-NEXT:    v_lshlrev_b32_e32 v2, 20, v2
892; WAVE64-OPT-NEXT:    s_load_dwordx4 s[20:23], s[20:21], 0x0
893; WAVE64-OPT-NEXT:    v_lshlrev_b32_e32 v1, 10, v1
894; WAVE64-OPT-NEXT:    s_movk_i32 s32, 0x2400
895; WAVE64-OPT-NEXT:    s_mov_b32 s13, s9
896; WAVE64-OPT-NEXT:    s_mov_b32 s12, s8
897; WAVE64-OPT-NEXT:    s_mov_b64 s[8:9], s[4:5]
898; WAVE64-OPT-NEXT:    s_mov_b32 s4, s32
899; WAVE64-OPT-NEXT:    v_mov_b32_e32 v3, 42
900; WAVE64-OPT-NEXT:    v_mov_b32_e32 v4, 17
901; WAVE64-OPT-NEXT:    v_or3_b32 v31, v0, v1, v2
902; WAVE64-OPT-NEXT:    s_mov_b32 s14, s10
903; WAVE64-OPT-NEXT:    s_mov_b32 s17, stack_passed_argument@abs32@hi
904; WAVE64-OPT-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
905; WAVE64-OPT-NEXT:    s_waitcnt lgkmcnt(0)
906; WAVE64-OPT-NEXT:    s_add_u32 s20, s20, s11
907; WAVE64-OPT-NEXT:    s_addc_u32 s21, s21, 0
908; WAVE64-OPT-NEXT:    s_mov_b64 s[10:11], s[6:7]
909; WAVE64-OPT-NEXT:    s_lshr_b32 s15, s4, 6
910; WAVE64-OPT-NEXT:    s_mov_b64 s[4:5], s[0:1]
911; WAVE64-OPT-NEXT:    s_mov_b64 s[6:7], s[2:3]
912; WAVE64-OPT-NEXT:    s_mov_b64 s[0:1], s[20:21]
913; WAVE64-OPT-NEXT:    s_mov_b64 s[2:3], s[22:23]
914; WAVE64-OPT-NEXT:    buffer_store_dword v3, off, s[20:23], 0
915; WAVE64-OPT-NEXT:    s_waitcnt_vscnt null, 0x0
916; WAVE64-OPT-NEXT:    buffer_store_dword v4, off, s[20:23], s32 offset:4
917; WAVE64-OPT-NEXT:    s_swappc_b64 s[30:31], s[16:17]
918; WAVE64-OPT-NEXT:    ;;#ASMSTART
919; WAVE64-OPT-NEXT:    ; use s15
920; WAVE64-OPT-NEXT:    ;;#ASMEND
921; WAVE64-OPT-NEXT:    s_endpgm
922;
923; WAVE32-O0-LABEL: kernel_stacksave_stackrestore_call_with_stack_objects:
924; WAVE32-O0:       ; %bb.0:
925; WAVE32-O0-NEXT:    s_mov_b32 s32, 0x1200
926; WAVE32-O0-NEXT:    s_getpc_b64 s[20:21]
927; WAVE32-O0-NEXT:    s_mov_b32 s20, s0
928; WAVE32-O0-NEXT:    s_load_dwordx4 s[20:23], s[20:21], 0x0
929; WAVE32-O0-NEXT:    s_waitcnt lgkmcnt(0)
930; WAVE32-O0-NEXT:    s_bitset0_b32 s23, 21
931; WAVE32-O0-NEXT:    s_add_u32 s20, s20, s11
932; WAVE32-O0-NEXT:    s_addc_u32 s21, s21, 0
933; WAVE32-O0-NEXT:    s_mov_b32 s14, s10
934; WAVE32-O0-NEXT:    s_mov_b32 s13, s9
935; WAVE32-O0-NEXT:    s_mov_b32 s12, s8
936; WAVE32-O0-NEXT:    s_mov_b64 s[10:11], s[6:7]
937; WAVE32-O0-NEXT:    s_mov_b64 s[8:9], s[4:5]
938; WAVE32-O0-NEXT:    s_mov_b64 s[6:7], s[2:3]
939; WAVE32-O0-NEXT:    s_mov_b64 s[4:5], s[0:1]
940; WAVE32-O0-NEXT:    s_mov_b32 s0, s32
941; WAVE32-O0-NEXT:    ; implicit-def: $vgpr32 : SGPR spill to VGPR lane
942; WAVE32-O0-NEXT:    v_writelane_b32 v32, s0, 0
943; WAVE32-O0-NEXT:    s_lshr_b32 s0, s0, 5
944; WAVE32-O0-NEXT:    v_writelane_b32 v32, s0, 1
945; WAVE32-O0-NEXT:    v_mov_b32_e32 v3, 42
946; WAVE32-O0-NEXT:    buffer_store_dword v3, off, s[20:23], 0
947; WAVE32-O0-NEXT:    s_waitcnt_vscnt null, 0x0
948; WAVE32-O0-NEXT:    s_mov_b64 s[0:1], s[20:21]
949; WAVE32-O0-NEXT:    s_mov_b64 s[2:3], s[22:23]
950; WAVE32-O0-NEXT:    s_mov_b32 s15, s32
951; WAVE32-O0-NEXT:    v_mov_b32_e32 v3, 17
952; WAVE32-O0-NEXT:    buffer_store_dword v3, off, s[20:23], s15 offset:4
953; WAVE32-O0-NEXT:    s_mov_b32 s15, stack_passed_argument@abs32@hi
954; WAVE32-O0-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
955; WAVE32-O0-NEXT:    ; kill: def $sgpr16 killed $sgpr16 def $sgpr16_sgpr17
956; WAVE32-O0-NEXT:    s_mov_b32 s17, s15
957; WAVE32-O0-NEXT:    s_mov_b32 s15, 20
958; WAVE32-O0-NEXT:    v_lshlrev_b32_e64 v2, s15, v2
959; WAVE32-O0-NEXT:    s_mov_b32 s15, 10
960; WAVE32-O0-NEXT:    v_lshlrev_b32_e64 v1, s15, v1
961; WAVE32-O0-NEXT:    v_or3_b32 v31, v0, v1, v2
962; WAVE32-O0-NEXT:    ; implicit-def: $sgpr15
963; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
964; WAVE32-O0-NEXT:    v_mov_b32_e32 v0, s18
965; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
966; WAVE32-O0-NEXT:    v_mov_b32_e32 v1, s18
967; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
968; WAVE32-O0-NEXT:    v_mov_b32_e32 v2, s18
969; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
970; WAVE32-O0-NEXT:    v_mov_b32_e32 v3, s18
971; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
972; WAVE32-O0-NEXT:    v_mov_b32_e32 v4, s18
973; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
974; WAVE32-O0-NEXT:    v_mov_b32_e32 v5, s18
975; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
976; WAVE32-O0-NEXT:    v_mov_b32_e32 v6, s18
977; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
978; WAVE32-O0-NEXT:    v_mov_b32_e32 v7, s18
979; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
980; WAVE32-O0-NEXT:    v_mov_b32_e32 v8, s18
981; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
982; WAVE32-O0-NEXT:    v_mov_b32_e32 v9, s18
983; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
984; WAVE32-O0-NEXT:    v_mov_b32_e32 v10, s18
985; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
986; WAVE32-O0-NEXT:    v_mov_b32_e32 v11, s18
987; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
988; WAVE32-O0-NEXT:    v_mov_b32_e32 v12, s18
989; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
990; WAVE32-O0-NEXT:    v_mov_b32_e32 v13, s18
991; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
992; WAVE32-O0-NEXT:    v_mov_b32_e32 v14, s18
993; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
994; WAVE32-O0-NEXT:    v_mov_b32_e32 v15, s18
995; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
996; WAVE32-O0-NEXT:    v_mov_b32_e32 v16, s18
997; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
998; WAVE32-O0-NEXT:    v_mov_b32_e32 v17, s18
999; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1000; WAVE32-O0-NEXT:    v_mov_b32_e32 v18, s18
1001; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1002; WAVE32-O0-NEXT:    v_mov_b32_e32 v19, s18
1003; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1004; WAVE32-O0-NEXT:    v_mov_b32_e32 v20, s18
1005; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1006; WAVE32-O0-NEXT:    v_mov_b32_e32 v21, s18
1007; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1008; WAVE32-O0-NEXT:    v_mov_b32_e32 v22, s18
1009; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1010; WAVE32-O0-NEXT:    v_mov_b32_e32 v23, s18
1011; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1012; WAVE32-O0-NEXT:    v_mov_b32_e32 v24, s18
1013; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1014; WAVE32-O0-NEXT:    v_mov_b32_e32 v25, s18
1015; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1016; WAVE32-O0-NEXT:    v_mov_b32_e32 v26, s18
1017; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1018; WAVE32-O0-NEXT:    v_mov_b32_e32 v27, s18
1019; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1020; WAVE32-O0-NEXT:    v_mov_b32_e32 v28, s18
1021; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1022; WAVE32-O0-NEXT:    v_mov_b32_e32 v29, s18
1023; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1024; WAVE32-O0-NEXT:    v_mov_b32_e32 v30, s18
1025; WAVE32-O0-NEXT:    s_swappc_b64 s[30:31], s[16:17]
1026; WAVE32-O0-NEXT:    v_readlane_b32 s1, v32, 1
1027; WAVE32-O0-NEXT:    v_readlane_b32 s0, v32, 0
1028; WAVE32-O0-NEXT:    ;;#ASMSTART
1029; WAVE32-O0-NEXT:    ; use s1
1030; WAVE32-O0-NEXT:    ;;#ASMEND
1031; WAVE32-O0-NEXT:    s_mov_b32 s32, s0
1032; WAVE32-O0-NEXT:    s_endpgm
1033;
1034; WAVE64-O0-LABEL: kernel_stacksave_stackrestore_call_with_stack_objects:
1035; WAVE64-O0:       ; %bb.0:
1036; WAVE64-O0-NEXT:    s_mov_b32 s32, 0x2400
1037; WAVE64-O0-NEXT:    s_getpc_b64 s[24:25]
1038; WAVE64-O0-NEXT:    s_mov_b32 s24, s0
1039; WAVE64-O0-NEXT:    s_load_dwordx4 s[24:27], s[24:25], 0x0
1040; WAVE64-O0-NEXT:    s_waitcnt lgkmcnt(0)
1041; WAVE64-O0-NEXT:    s_add_u32 s24, s24, s11
1042; WAVE64-O0-NEXT:    s_addc_u32 s25, s25, 0
1043; WAVE64-O0-NEXT:    s_mov_b32 s14, s10
1044; WAVE64-O0-NEXT:    s_mov_b32 s13, s9
1045; WAVE64-O0-NEXT:    s_mov_b32 s12, s8
1046; WAVE64-O0-NEXT:    s_mov_b64 s[10:11], s[6:7]
1047; WAVE64-O0-NEXT:    s_mov_b64 s[8:9], s[4:5]
1048; WAVE64-O0-NEXT:    s_mov_b64 s[6:7], s[2:3]
1049; WAVE64-O0-NEXT:    s_mov_b64 s[4:5], s[0:1]
1050; WAVE64-O0-NEXT:    s_mov_b32 s0, s32
1051; WAVE64-O0-NEXT:    ; implicit-def: $vgpr32 : SGPR spill to VGPR lane
1052; WAVE64-O0-NEXT:    v_writelane_b32 v32, s0, 0
1053; WAVE64-O0-NEXT:    s_lshr_b32 s0, s0, 6
1054; WAVE64-O0-NEXT:    v_writelane_b32 v32, s0, 1
1055; WAVE64-O0-NEXT:    v_mov_b32_e32 v3, 42
1056; WAVE64-O0-NEXT:    buffer_store_dword v3, off, s[24:27], 0
1057; WAVE64-O0-NEXT:    s_waitcnt_vscnt null, 0x0
1058; WAVE64-O0-NEXT:    s_mov_b64 s[0:1], s[24:25]
1059; WAVE64-O0-NEXT:    s_mov_b64 s[2:3], s[26:27]
1060; WAVE64-O0-NEXT:    s_mov_b32 s15, s32
1061; WAVE64-O0-NEXT:    v_mov_b32_e32 v3, 17
1062; WAVE64-O0-NEXT:    buffer_store_dword v3, off, s[24:27], s15 offset:4
1063; WAVE64-O0-NEXT:    s_mov_b32 s15, stack_passed_argument@abs32@hi
1064; WAVE64-O0-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
1065; WAVE64-O0-NEXT:    ; kill: def $sgpr16 killed $sgpr16 def $sgpr16_sgpr17
1066; WAVE64-O0-NEXT:    s_mov_b32 s17, s15
1067; WAVE64-O0-NEXT:    s_mov_b32 s15, 20
1068; WAVE64-O0-NEXT:    v_lshlrev_b32_e64 v2, s15, v2
1069; WAVE64-O0-NEXT:    s_mov_b32 s15, 10
1070; WAVE64-O0-NEXT:    v_lshlrev_b32_e64 v1, s15, v1
1071; WAVE64-O0-NEXT:    v_or3_b32 v31, v0, v1, v2
1072; WAVE64-O0-NEXT:    ; implicit-def: $sgpr15
1073; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1074; WAVE64-O0-NEXT:    v_mov_b32_e32 v0, s18
1075; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1076; WAVE64-O0-NEXT:    v_mov_b32_e32 v1, s18
1077; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1078; WAVE64-O0-NEXT:    v_mov_b32_e32 v2, s18
1079; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1080; WAVE64-O0-NEXT:    v_mov_b32_e32 v3, s18
1081; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1082; WAVE64-O0-NEXT:    v_mov_b32_e32 v4, s18
1083; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1084; WAVE64-O0-NEXT:    v_mov_b32_e32 v5, s18
1085; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1086; WAVE64-O0-NEXT:    v_mov_b32_e32 v6, s18
1087; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1088; WAVE64-O0-NEXT:    v_mov_b32_e32 v7, s18
1089; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1090; WAVE64-O0-NEXT:    v_mov_b32_e32 v8, s18
1091; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1092; WAVE64-O0-NEXT:    v_mov_b32_e32 v9, s18
1093; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1094; WAVE64-O0-NEXT:    v_mov_b32_e32 v10, s18
1095; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1096; WAVE64-O0-NEXT:    v_mov_b32_e32 v11, s18
1097; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1098; WAVE64-O0-NEXT:    v_mov_b32_e32 v12, s18
1099; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1100; WAVE64-O0-NEXT:    v_mov_b32_e32 v13, s18
1101; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1102; WAVE64-O0-NEXT:    v_mov_b32_e32 v14, s18
1103; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1104; WAVE64-O0-NEXT:    v_mov_b32_e32 v15, s18
1105; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1106; WAVE64-O0-NEXT:    v_mov_b32_e32 v16, s18
1107; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1108; WAVE64-O0-NEXT:    v_mov_b32_e32 v17, s18
1109; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1110; WAVE64-O0-NEXT:    v_mov_b32_e32 v18, s18
1111; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1112; WAVE64-O0-NEXT:    v_mov_b32_e32 v19, s18
1113; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1114; WAVE64-O0-NEXT:    v_mov_b32_e32 v20, s18
1115; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1116; WAVE64-O0-NEXT:    v_mov_b32_e32 v21, s18
1117; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1118; WAVE64-O0-NEXT:    v_mov_b32_e32 v22, s18
1119; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1120; WAVE64-O0-NEXT:    v_mov_b32_e32 v23, s18
1121; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1122; WAVE64-O0-NEXT:    v_mov_b32_e32 v24, s18
1123; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1124; WAVE64-O0-NEXT:    v_mov_b32_e32 v25, s18
1125; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1126; WAVE64-O0-NEXT:    v_mov_b32_e32 v26, s18
1127; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1128; WAVE64-O0-NEXT:    v_mov_b32_e32 v27, s18
1129; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1130; WAVE64-O0-NEXT:    v_mov_b32_e32 v28, s18
1131; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1132; WAVE64-O0-NEXT:    v_mov_b32_e32 v29, s18
1133; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1134; WAVE64-O0-NEXT:    v_mov_b32_e32 v30, s18
1135; WAVE64-O0-NEXT:    s_swappc_b64 s[30:31], s[16:17]
1136; WAVE64-O0-NEXT:    v_readlane_b32 s1, v32, 1
1137; WAVE64-O0-NEXT:    v_readlane_b32 s0, v32, 0
1138; WAVE64-O0-NEXT:    ;;#ASMSTART
1139; WAVE64-O0-NEXT:    ; use s1
1140; WAVE64-O0-NEXT:    ;;#ASMEND
1141; WAVE64-O0-NEXT:    s_mov_b32 s32, s0
1142; WAVE64-O0-NEXT:    s_endpgm
1143;
1144; WAVE32-WWM-PREALLOC-LABEL: kernel_stacksave_stackrestore_call_with_stack_objects:
1145; WAVE32-WWM-PREALLOC:       ; %bb.0:
1146; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, 0x1200
1147; WAVE32-WWM-PREALLOC-NEXT:    s_getpc_b64 s[20:21]
1148; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s20, s0
1149; WAVE32-WWM-PREALLOC-NEXT:    s_load_dwordx4 s[20:23], s[20:21], 0x0
1150; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt lgkmcnt(0)
1151; WAVE32-WWM-PREALLOC-NEXT:    s_bitset0_b32 s23, 21
1152; WAVE32-WWM-PREALLOC-NEXT:    s_add_u32 s20, s20, s11
1153; WAVE32-WWM-PREALLOC-NEXT:    s_addc_u32 s21, s21, 0
1154; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s14, s10
1155; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s13, s9
1156; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s12, s8
1157; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[10:11], s[6:7]
1158; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[8:9], s[4:5]
1159; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[6:7], s[2:3]
1160; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[4:5], s[0:1]
1161; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s0, s32
1162; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $vgpr32 : SGPR spill to VGPR lane
1163; WAVE32-WWM-PREALLOC-NEXT:    v_writelane_b32 v32, s0, 0
1164; WAVE32-WWM-PREALLOC-NEXT:    s_lshr_b32 s0, s0, 5
1165; WAVE32-WWM-PREALLOC-NEXT:    v_writelane_b32 v32, s0, 1
1166; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v3, 42
1167; WAVE32-WWM-PREALLOC-NEXT:    buffer_store_dword v3, off, s[20:23], 0
1168; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt_vscnt null, 0x0
1169; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[0:1], s[20:21]
1170; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[2:3], s[22:23]
1171; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s15, s32
1172; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v3, 17
1173; WAVE32-WWM-PREALLOC-NEXT:    buffer_store_dword v3, off, s[20:23], s15 offset:4
1174; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s15, stack_passed_argument@abs32@hi
1175; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
1176; WAVE32-WWM-PREALLOC-NEXT:    ; kill: def $sgpr16 killed $sgpr16 def $sgpr16_sgpr17
1177; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s17, s15
1178; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s15, 20
1179; WAVE32-WWM-PREALLOC-NEXT:    v_lshlrev_b32_e64 v2, s15, v2
1180; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s15, 10
1181; WAVE32-WWM-PREALLOC-NEXT:    v_lshlrev_b32_e64 v1, s15, v1
1182; WAVE32-WWM-PREALLOC-NEXT:    v_or3_b32 v31, v0, v1, v2
1183; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr15
1184; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1185; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v0, s18
1186; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1187; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v1, s18
1188; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1189; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v2, s18
1190; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1191; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v3, s18
1192; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1193; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v4, s18
1194; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1195; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v5, s18
1196; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1197; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v6, s18
1198; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1199; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v7, s18
1200; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1201; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v8, s18
1202; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1203; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v9, s18
1204; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1205; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v10, s18
1206; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1207; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v11, s18
1208; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1209; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v12, s18
1210; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1211; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v13, s18
1212; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1213; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v14, s18
1214; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1215; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v15, s18
1216; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1217; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v16, s18
1218; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1219; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v17, s18
1220; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1221; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v18, s18
1222; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1223; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v19, s18
1224; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1225; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v20, s18
1226; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1227; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v21, s18
1228; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1229; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v22, s18
1230; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1231; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v23, s18
1232; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1233; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v24, s18
1234; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1235; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v25, s18
1236; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1237; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v26, s18
1238; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1239; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v27, s18
1240; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1241; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v28, s18
1242; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1243; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v29, s18
1244; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1245; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v30, s18
1246; WAVE32-WWM-PREALLOC-NEXT:    s_swappc_b64 s[30:31], s[16:17]
1247; WAVE32-WWM-PREALLOC-NEXT:    v_readlane_b32 s1, v32, 1
1248; WAVE32-WWM-PREALLOC-NEXT:    v_readlane_b32 s0, v32, 0
1249; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMSTART
1250; WAVE32-WWM-PREALLOC-NEXT:    ; use s1
1251; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMEND
1252; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s0
1253; WAVE32-WWM-PREALLOC-NEXT:    s_endpgm
1254  %alloca = alloca [32 x i32], addrspace(5)
1255  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
1256  store volatile i32 42, ptr addrspace(5) %alloca
1257  call void @stack_passed_argument([32 x i32] poison, i32 17)
1258  call void asm sideeffect "; use $0", "s"(ptr addrspace(5) %stacksave)
1259  call void @llvm.stackrestore.p5(ptr addrspace(5) %stacksave)
1260  ret void
1261}
1262
1263define void @func_stacksave_stackrestore_call_with_stack_objects() {
1264; WAVE32-OPT-LABEL: func_stacksave_stackrestore_call_with_stack_objects:
1265; WAVE32-OPT:       ; %bb.0:
1266; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1267; WAVE32-OPT-NEXT:    s_mov_b32 s20, s33
1268; WAVE32-OPT-NEXT:    s_mov_b32 s33, s32
1269; WAVE32-OPT-NEXT:    s_xor_saveexec_b32 s16, -1
1270; WAVE32-OPT-NEXT:    buffer_store_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Spill
1271; WAVE32-OPT-NEXT:    s_mov_b32 exec_lo, s16
1272; WAVE32-OPT-NEXT:    v_writelane_b32 v32, s30, 0
1273; WAVE32-OPT-NEXT:    v_mov_b32_e32 v0, 42
1274; WAVE32-OPT-NEXT:    v_mov_b32_e32 v1, 17
1275; WAVE32-OPT-NEXT:    s_addk_i32 s32, 0x1200
1276; WAVE32-OPT-NEXT:    s_mov_b32 s17, stack_passed_argument@abs32@hi
1277; WAVE32-OPT-NEXT:    s_mov_b32 s18, s32
1278; WAVE32-OPT-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
1279; WAVE32-OPT-NEXT:    v_writelane_b32 v32, s31, 1
1280; WAVE32-OPT-NEXT:    s_lshr_b32 s19, s18, 5
1281; WAVE32-OPT-NEXT:    buffer_store_dword v0, off, s[0:3], s33
1282; WAVE32-OPT-NEXT:    s_waitcnt_vscnt null, 0x0
1283; WAVE32-OPT-NEXT:    buffer_store_dword v1, off, s[0:3], s32 offset:4
1284; WAVE32-OPT-NEXT:    s_swappc_b64 s[30:31], s[16:17]
1285; WAVE32-OPT-NEXT:    s_mov_b32 s32, s18
1286; WAVE32-OPT-NEXT:    ;;#ASMSTART
1287; WAVE32-OPT-NEXT:    ; use s19
1288; WAVE32-OPT-NEXT:    ;;#ASMEND
1289; WAVE32-OPT-NEXT:    v_readlane_b32 s31, v32, 1
1290; WAVE32-OPT-NEXT:    v_readlane_b32 s30, v32, 0
1291; WAVE32-OPT-NEXT:    s_mov_b32 s32, s33
1292; WAVE32-OPT-NEXT:    s_xor_saveexec_b32 s4, -1
1293; WAVE32-OPT-NEXT:    buffer_load_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Reload
1294; WAVE32-OPT-NEXT:    s_mov_b32 exec_lo, s4
1295; WAVE32-OPT-NEXT:    s_mov_b32 s33, s20
1296; WAVE32-OPT-NEXT:    s_waitcnt vmcnt(0)
1297; WAVE32-OPT-NEXT:    s_setpc_b64 s[30:31]
1298;
1299; WAVE64-OPT-LABEL: func_stacksave_stackrestore_call_with_stack_objects:
1300; WAVE64-OPT:       ; %bb.0:
1301; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1302; WAVE64-OPT-NEXT:    s_mov_b32 s20, s33
1303; WAVE64-OPT-NEXT:    s_mov_b32 s33, s32
1304; WAVE64-OPT-NEXT:    s_xor_saveexec_b64 s[16:17], -1
1305; WAVE64-OPT-NEXT:    buffer_store_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Spill
1306; WAVE64-OPT-NEXT:    s_mov_b64 exec, s[16:17]
1307; WAVE64-OPT-NEXT:    v_writelane_b32 v32, s30, 0
1308; WAVE64-OPT-NEXT:    v_mov_b32_e32 v0, 42
1309; WAVE64-OPT-NEXT:    v_mov_b32_e32 v1, 17
1310; WAVE64-OPT-NEXT:    s_addk_i32 s32, 0x2400
1311; WAVE64-OPT-NEXT:    s_mov_b32 s17, stack_passed_argument@abs32@hi
1312; WAVE64-OPT-NEXT:    s_mov_b32 s18, s32
1313; WAVE64-OPT-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
1314; WAVE64-OPT-NEXT:    v_writelane_b32 v32, s31, 1
1315; WAVE64-OPT-NEXT:    s_lshr_b32 s19, s18, 6
1316; WAVE64-OPT-NEXT:    buffer_store_dword v0, off, s[0:3], s33
1317; WAVE64-OPT-NEXT:    s_waitcnt_vscnt null, 0x0
1318; WAVE64-OPT-NEXT:    buffer_store_dword v1, off, s[0:3], s32 offset:4
1319; WAVE64-OPT-NEXT:    s_swappc_b64 s[30:31], s[16:17]
1320; WAVE64-OPT-NEXT:    s_mov_b32 s32, s18
1321; WAVE64-OPT-NEXT:    ;;#ASMSTART
1322; WAVE64-OPT-NEXT:    ; use s19
1323; WAVE64-OPT-NEXT:    ;;#ASMEND
1324; WAVE64-OPT-NEXT:    v_readlane_b32 s31, v32, 1
1325; WAVE64-OPT-NEXT:    v_readlane_b32 s30, v32, 0
1326; WAVE64-OPT-NEXT:    s_mov_b32 s32, s33
1327; WAVE64-OPT-NEXT:    s_xor_saveexec_b64 s[4:5], -1
1328; WAVE64-OPT-NEXT:    buffer_load_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Reload
1329; WAVE64-OPT-NEXT:    s_mov_b64 exec, s[4:5]
1330; WAVE64-OPT-NEXT:    s_mov_b32 s33, s20
1331; WAVE64-OPT-NEXT:    s_waitcnt vmcnt(0)
1332; WAVE64-OPT-NEXT:    s_setpc_b64 s[30:31]
1333;
1334; WAVE32-O0-LABEL: func_stacksave_stackrestore_call_with_stack_objects:
1335; WAVE32-O0:       ; %bb.0:
1336; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1337; WAVE32-O0-NEXT:    s_mov_b32 s24, s33
1338; WAVE32-O0-NEXT:    s_mov_b32 s33, s32
1339; WAVE32-O0-NEXT:    s_xor_saveexec_b32 s16, -1
1340; WAVE32-O0-NEXT:    buffer_store_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Spill
1341; WAVE32-O0-NEXT:    buffer_store_dword v33, off, s[0:3], s33 offset:132 ; 4-byte Folded Spill
1342; WAVE32-O0-NEXT:    s_mov_b32 exec_lo, s16
1343; WAVE32-O0-NEXT:    s_add_i32 s32, s32, 0x1200
1344; WAVE32-O0-NEXT:    v_writelane_b32 v32, s30, 0
1345; WAVE32-O0-NEXT:    v_writelane_b32 v32, s31, 1
1346; WAVE32-O0-NEXT:    s_mov_b32 s16, s32
1347; WAVE32-O0-NEXT:    ; implicit-def: $vgpr33 : SGPR spill to VGPR lane
1348; WAVE32-O0-NEXT:    v_writelane_b32 v33, s16, 0
1349; WAVE32-O0-NEXT:    s_lshr_b32 s16, s16, 5
1350; WAVE32-O0-NEXT:    v_writelane_b32 v33, s16, 1
1351; WAVE32-O0-NEXT:    v_mov_b32_e32 v0, 42
1352; WAVE32-O0-NEXT:    buffer_store_dword v0, off, s[0:3], s33
1353; WAVE32-O0-NEXT:    s_waitcnt_vscnt null, 0x0
1354; WAVE32-O0-NEXT:    s_mov_b64 s[22:23], s[2:3]
1355; WAVE32-O0-NEXT:    s_mov_b64 s[20:21], s[0:1]
1356; WAVE32-O0-NEXT:    s_mov_b32 s16, s32
1357; WAVE32-O0-NEXT:    v_mov_b32_e32 v0, 17
1358; WAVE32-O0-NEXT:    buffer_store_dword v0, off, s[0:3], s16 offset:4
1359; WAVE32-O0-NEXT:    s_mov_b32 s18, stack_passed_argument@abs32@hi
1360; WAVE32-O0-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
1361; WAVE32-O0-NEXT:    ; kill: def $sgpr16 killed $sgpr16 def $sgpr16_sgpr17
1362; WAVE32-O0-NEXT:    s_mov_b32 s17, s18
1363; WAVE32-O0-NEXT:    s_mov_b64 s[0:1], s[20:21]
1364; WAVE32-O0-NEXT:    s_mov_b64 s[2:3], s[22:23]
1365; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1366; WAVE32-O0-NEXT:    v_mov_b32_e32 v0, s18
1367; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1368; WAVE32-O0-NEXT:    v_mov_b32_e32 v1, s18
1369; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1370; WAVE32-O0-NEXT:    v_mov_b32_e32 v2, s18
1371; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1372; WAVE32-O0-NEXT:    v_mov_b32_e32 v3, s18
1373; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1374; WAVE32-O0-NEXT:    v_mov_b32_e32 v4, s18
1375; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1376; WAVE32-O0-NEXT:    v_mov_b32_e32 v5, s18
1377; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1378; WAVE32-O0-NEXT:    v_mov_b32_e32 v6, s18
1379; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1380; WAVE32-O0-NEXT:    v_mov_b32_e32 v7, s18
1381; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1382; WAVE32-O0-NEXT:    v_mov_b32_e32 v8, s18
1383; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1384; WAVE32-O0-NEXT:    v_mov_b32_e32 v9, s18
1385; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1386; WAVE32-O0-NEXT:    v_mov_b32_e32 v10, s18
1387; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1388; WAVE32-O0-NEXT:    v_mov_b32_e32 v11, s18
1389; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1390; WAVE32-O0-NEXT:    v_mov_b32_e32 v12, s18
1391; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1392; WAVE32-O0-NEXT:    v_mov_b32_e32 v13, s18
1393; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1394; WAVE32-O0-NEXT:    v_mov_b32_e32 v14, s18
1395; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1396; WAVE32-O0-NEXT:    v_mov_b32_e32 v15, s18
1397; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1398; WAVE32-O0-NEXT:    v_mov_b32_e32 v16, s18
1399; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1400; WAVE32-O0-NEXT:    v_mov_b32_e32 v17, s18
1401; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1402; WAVE32-O0-NEXT:    v_mov_b32_e32 v18, s18
1403; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1404; WAVE32-O0-NEXT:    v_mov_b32_e32 v19, s18
1405; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1406; WAVE32-O0-NEXT:    v_mov_b32_e32 v20, s18
1407; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1408; WAVE32-O0-NEXT:    v_mov_b32_e32 v21, s18
1409; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1410; WAVE32-O0-NEXT:    v_mov_b32_e32 v22, s18
1411; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1412; WAVE32-O0-NEXT:    v_mov_b32_e32 v23, s18
1413; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1414; WAVE32-O0-NEXT:    v_mov_b32_e32 v24, s18
1415; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1416; WAVE32-O0-NEXT:    v_mov_b32_e32 v25, s18
1417; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1418; WAVE32-O0-NEXT:    v_mov_b32_e32 v26, s18
1419; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1420; WAVE32-O0-NEXT:    v_mov_b32_e32 v27, s18
1421; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1422; WAVE32-O0-NEXT:    v_mov_b32_e32 v28, s18
1423; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1424; WAVE32-O0-NEXT:    v_mov_b32_e32 v29, s18
1425; WAVE32-O0-NEXT:    ; implicit-def: $sgpr18
1426; WAVE32-O0-NEXT:    v_mov_b32_e32 v30, s18
1427; WAVE32-O0-NEXT:    s_swappc_b64 s[30:31], s[16:17]
1428; WAVE32-O0-NEXT:    v_readlane_b32 s5, v33, 1
1429; WAVE32-O0-NEXT:    v_readlane_b32 s4, v33, 0
1430; WAVE32-O0-NEXT:    ;;#ASMSTART
1431; WAVE32-O0-NEXT:    ; use s5
1432; WAVE32-O0-NEXT:    ;;#ASMEND
1433; WAVE32-O0-NEXT:    s_mov_b32 s32, s4
1434; WAVE32-O0-NEXT:    v_readlane_b32 s31, v32, 1
1435; WAVE32-O0-NEXT:    v_readlane_b32 s30, v32, 0
1436; WAVE32-O0-NEXT:    s_mov_b32 s32, s33
1437; WAVE32-O0-NEXT:    s_xor_saveexec_b32 s4, -1
1438; WAVE32-O0-NEXT:    buffer_load_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Reload
1439; WAVE32-O0-NEXT:    buffer_load_dword v33, off, s[0:3], s33 offset:132 ; 4-byte Folded Reload
1440; WAVE32-O0-NEXT:    s_mov_b32 exec_lo, s4
1441; WAVE32-O0-NEXT:    s_mov_b32 s33, s24
1442; WAVE32-O0-NEXT:    s_waitcnt vmcnt(0)
1443; WAVE32-O0-NEXT:    s_setpc_b64 s[30:31]
1444;
1445; WAVE64-O0-LABEL: func_stacksave_stackrestore_call_with_stack_objects:
1446; WAVE64-O0:       ; %bb.0:
1447; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1448; WAVE64-O0-NEXT:    s_mov_b32 s19, s33
1449; WAVE64-O0-NEXT:    s_mov_b32 s33, s32
1450; WAVE64-O0-NEXT:    s_xor_saveexec_b64 s[16:17], -1
1451; WAVE64-O0-NEXT:    buffer_store_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Spill
1452; WAVE64-O0-NEXT:    buffer_store_dword v33, off, s[0:3], s33 offset:132 ; 4-byte Folded Spill
1453; WAVE64-O0-NEXT:    s_mov_b64 exec, s[16:17]
1454; WAVE64-O0-NEXT:    s_add_i32 s32, s32, 0x2400
1455; WAVE64-O0-NEXT:    v_writelane_b32 v32, s30, 0
1456; WAVE64-O0-NEXT:    v_writelane_b32 v32, s31, 1
1457; WAVE64-O0-NEXT:    s_mov_b32 s16, s32
1458; WAVE64-O0-NEXT:    ; implicit-def: $vgpr33 : SGPR spill to VGPR lane
1459; WAVE64-O0-NEXT:    v_writelane_b32 v33, s16, 0
1460; WAVE64-O0-NEXT:    s_lshr_b32 s16, s16, 6
1461; WAVE64-O0-NEXT:    v_writelane_b32 v33, s16, 1
1462; WAVE64-O0-NEXT:    v_mov_b32_e32 v0, 42
1463; WAVE64-O0-NEXT:    buffer_store_dword v0, off, s[0:3], s33
1464; WAVE64-O0-NEXT:    s_waitcnt_vscnt null, 0x0
1465; WAVE64-O0-NEXT:    s_mov_b64 s[22:23], s[2:3]
1466; WAVE64-O0-NEXT:    s_mov_b64 s[20:21], s[0:1]
1467; WAVE64-O0-NEXT:    s_mov_b32 s16, s32
1468; WAVE64-O0-NEXT:    v_mov_b32_e32 v0, 17
1469; WAVE64-O0-NEXT:    buffer_store_dword v0, off, s[0:3], s16 offset:4
1470; WAVE64-O0-NEXT:    s_mov_b32 s18, stack_passed_argument@abs32@hi
1471; WAVE64-O0-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
1472; WAVE64-O0-NEXT:    ; kill: def $sgpr16 killed $sgpr16 def $sgpr16_sgpr17
1473; WAVE64-O0-NEXT:    s_mov_b32 s17, s18
1474; WAVE64-O0-NEXT:    s_mov_b64 s[0:1], s[20:21]
1475; WAVE64-O0-NEXT:    s_mov_b64 s[2:3], s[22:23]
1476; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1477; WAVE64-O0-NEXT:    v_mov_b32_e32 v0, s18
1478; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1479; WAVE64-O0-NEXT:    v_mov_b32_e32 v1, s18
1480; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1481; WAVE64-O0-NEXT:    v_mov_b32_e32 v2, s18
1482; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1483; WAVE64-O0-NEXT:    v_mov_b32_e32 v3, s18
1484; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1485; WAVE64-O0-NEXT:    v_mov_b32_e32 v4, s18
1486; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1487; WAVE64-O0-NEXT:    v_mov_b32_e32 v5, s18
1488; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1489; WAVE64-O0-NEXT:    v_mov_b32_e32 v6, s18
1490; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1491; WAVE64-O0-NEXT:    v_mov_b32_e32 v7, s18
1492; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1493; WAVE64-O0-NEXT:    v_mov_b32_e32 v8, s18
1494; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1495; WAVE64-O0-NEXT:    v_mov_b32_e32 v9, s18
1496; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1497; WAVE64-O0-NEXT:    v_mov_b32_e32 v10, s18
1498; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1499; WAVE64-O0-NEXT:    v_mov_b32_e32 v11, s18
1500; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1501; WAVE64-O0-NEXT:    v_mov_b32_e32 v12, s18
1502; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1503; WAVE64-O0-NEXT:    v_mov_b32_e32 v13, s18
1504; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1505; WAVE64-O0-NEXT:    v_mov_b32_e32 v14, s18
1506; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1507; WAVE64-O0-NEXT:    v_mov_b32_e32 v15, s18
1508; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1509; WAVE64-O0-NEXT:    v_mov_b32_e32 v16, s18
1510; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1511; WAVE64-O0-NEXT:    v_mov_b32_e32 v17, s18
1512; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1513; WAVE64-O0-NEXT:    v_mov_b32_e32 v18, s18
1514; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1515; WAVE64-O0-NEXT:    v_mov_b32_e32 v19, s18
1516; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1517; WAVE64-O0-NEXT:    v_mov_b32_e32 v20, s18
1518; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1519; WAVE64-O0-NEXT:    v_mov_b32_e32 v21, s18
1520; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1521; WAVE64-O0-NEXT:    v_mov_b32_e32 v22, s18
1522; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1523; WAVE64-O0-NEXT:    v_mov_b32_e32 v23, s18
1524; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1525; WAVE64-O0-NEXT:    v_mov_b32_e32 v24, s18
1526; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1527; WAVE64-O0-NEXT:    v_mov_b32_e32 v25, s18
1528; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1529; WAVE64-O0-NEXT:    v_mov_b32_e32 v26, s18
1530; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1531; WAVE64-O0-NEXT:    v_mov_b32_e32 v27, s18
1532; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1533; WAVE64-O0-NEXT:    v_mov_b32_e32 v28, s18
1534; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1535; WAVE64-O0-NEXT:    v_mov_b32_e32 v29, s18
1536; WAVE64-O0-NEXT:    ; implicit-def: $sgpr18
1537; WAVE64-O0-NEXT:    v_mov_b32_e32 v30, s18
1538; WAVE64-O0-NEXT:    s_swappc_b64 s[30:31], s[16:17]
1539; WAVE64-O0-NEXT:    v_readlane_b32 s5, v33, 1
1540; WAVE64-O0-NEXT:    v_readlane_b32 s4, v33, 0
1541; WAVE64-O0-NEXT:    ;;#ASMSTART
1542; WAVE64-O0-NEXT:    ; use s5
1543; WAVE64-O0-NEXT:    ;;#ASMEND
1544; WAVE64-O0-NEXT:    s_mov_b32 s32, s4
1545; WAVE64-O0-NEXT:    v_readlane_b32 s31, v32, 1
1546; WAVE64-O0-NEXT:    v_readlane_b32 s30, v32, 0
1547; WAVE64-O0-NEXT:    s_mov_b32 s32, s33
1548; WAVE64-O0-NEXT:    s_xor_saveexec_b64 s[4:5], -1
1549; WAVE64-O0-NEXT:    buffer_load_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Reload
1550; WAVE64-O0-NEXT:    buffer_load_dword v33, off, s[0:3], s33 offset:132 ; 4-byte Folded Reload
1551; WAVE64-O0-NEXT:    s_mov_b64 exec, s[4:5]
1552; WAVE64-O0-NEXT:    s_mov_b32 s33, s19
1553; WAVE64-O0-NEXT:    s_waitcnt vmcnt(0)
1554; WAVE64-O0-NEXT:    s_setpc_b64 s[30:31]
1555;
1556; WAVE32-WWM-PREALLOC-LABEL: func_stacksave_stackrestore_call_with_stack_objects:
1557; WAVE32-WWM-PREALLOC:       ; %bb.0:
1558; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1559; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s24, s33
1560; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s33, s32
1561; WAVE32-WWM-PREALLOC-NEXT:    s_xor_saveexec_b32 s16, -1
1562; WAVE32-WWM-PREALLOC-NEXT:    buffer_store_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Spill
1563; WAVE32-WWM-PREALLOC-NEXT:    buffer_store_dword v33, off, s[0:3], s33 offset:132 ; 4-byte Folded Spill
1564; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 exec_lo, s16
1565; WAVE32-WWM-PREALLOC-NEXT:    s_add_i32 s32, s32, 0x1200
1566; WAVE32-WWM-PREALLOC-NEXT:    v_writelane_b32 v33, s30, 0
1567; WAVE32-WWM-PREALLOC-NEXT:    v_writelane_b32 v33, s31, 1
1568; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s16, s32
1569; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $vgpr32 : SGPR spill to VGPR lane
1570; WAVE32-WWM-PREALLOC-NEXT:    v_writelane_b32 v32, s16, 0
1571; WAVE32-WWM-PREALLOC-NEXT:    s_lshr_b32 s16, s16, 5
1572; WAVE32-WWM-PREALLOC-NEXT:    v_writelane_b32 v32, s16, 1
1573; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v0, 42
1574; WAVE32-WWM-PREALLOC-NEXT:    buffer_store_dword v0, off, s[0:3], s33
1575; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt_vscnt null, 0x0
1576; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[22:23], s[2:3]
1577; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[20:21], s[0:1]
1578; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s16, s32
1579; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v0, 17
1580; WAVE32-WWM-PREALLOC-NEXT:    buffer_store_dword v0, off, s[0:3], s16 offset:4
1581; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s18, stack_passed_argument@abs32@hi
1582; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s16, stack_passed_argument@abs32@lo
1583; WAVE32-WWM-PREALLOC-NEXT:    ; kill: def $sgpr16 killed $sgpr16 def $sgpr16_sgpr17
1584; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s17, s18
1585; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[0:1], s[20:21]
1586; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b64 s[2:3], s[22:23]
1587; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1588; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v0, s18
1589; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1590; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v1, s18
1591; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1592; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v2, s18
1593; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1594; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v3, s18
1595; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1596; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v4, s18
1597; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1598; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v5, s18
1599; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1600; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v6, s18
1601; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1602; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v7, s18
1603; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1604; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v8, s18
1605; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1606; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v9, s18
1607; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1608; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v10, s18
1609; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1610; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v11, s18
1611; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1612; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v12, s18
1613; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1614; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v13, s18
1615; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1616; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v14, s18
1617; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1618; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v15, s18
1619; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1620; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v16, s18
1621; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1622; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v17, s18
1623; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1624; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v18, s18
1625; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1626; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v19, s18
1627; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1628; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v20, s18
1629; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1630; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v21, s18
1631; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1632; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v22, s18
1633; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1634; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v23, s18
1635; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1636; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v24, s18
1637; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1638; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v25, s18
1639; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1640; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v26, s18
1641; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1642; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v27, s18
1643; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1644; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v28, s18
1645; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1646; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v29, s18
1647; WAVE32-WWM-PREALLOC-NEXT:    ; implicit-def: $sgpr18
1648; WAVE32-WWM-PREALLOC-NEXT:    v_mov_b32_e32 v30, s18
1649; WAVE32-WWM-PREALLOC-NEXT:    s_swappc_b64 s[30:31], s[16:17]
1650; WAVE32-WWM-PREALLOC-NEXT:    v_readlane_b32 s5, v32, 1
1651; WAVE32-WWM-PREALLOC-NEXT:    v_readlane_b32 s4, v32, 0
1652; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMSTART
1653; WAVE32-WWM-PREALLOC-NEXT:    ; use s5
1654; WAVE32-WWM-PREALLOC-NEXT:    ;;#ASMEND
1655; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s4
1656; WAVE32-WWM-PREALLOC-NEXT:    v_readlane_b32 s31, v33, 1
1657; WAVE32-WWM-PREALLOC-NEXT:    v_readlane_b32 s30, v33, 0
1658; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s32, s33
1659; WAVE32-WWM-PREALLOC-NEXT:    s_xor_saveexec_b32 s4, -1
1660; WAVE32-WWM-PREALLOC-NEXT:    buffer_load_dword v32, off, s[0:3], s33 offset:128 ; 4-byte Folded Reload
1661; WAVE32-WWM-PREALLOC-NEXT:    buffer_load_dword v33, off, s[0:3], s33 offset:132 ; 4-byte Folded Reload
1662; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 exec_lo, s4
1663; WAVE32-WWM-PREALLOC-NEXT:    s_mov_b32 s33, s24
1664; WAVE32-WWM-PREALLOC-NEXT:    s_waitcnt vmcnt(0)
1665; WAVE32-WWM-PREALLOC-NEXT:    s_setpc_b64 s[30:31]
1666  %alloca = alloca [32 x i32], addrspace(5)
1667  %stacksave = call ptr addrspace(5) @llvm.stacksave.p5()
1668  store volatile i32 42, ptr addrspace(5) %alloca
1669  call void @stack_passed_argument([32 x i32] poison, i32 17)
1670  call void asm sideeffect "; use $0", "s"(ptr addrspace(5) %stacksave)
1671  call void @llvm.stackrestore.p5(ptr addrspace(5) %stacksave)
1672  ret void
1673}
1674
1675!llvm.module.flags = !{!0}
1676!0 = !{i32 1, !"amdhsa_code_object_version", i32 500}
1677
1678;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
1679; WAVE32: {{.*}}
1680; WAVE64: {{.*}}
1681