1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 --amdgpu-enable-flat-scratch < %s | FileCheck -check-prefixes=GCN %s
4 declare void @extern_func() #0
6 define amdgpu_kernel void @stack_object_addrspacecast_in_kernel_no_calls() {
7 ; GCN-LABEL: stack_object_addrspacecast_in_kernel_no_calls:
9 ; GCN-NEXT: s_add_u32 s0, s0, s3
10 ; GCN-NEXT: s_addc_u32 s1, s1, 0
11 ; GCN-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s0
12 ; GCN-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s1
13 ; GCN-NEXT: v_mov_b32_e32 v0, 4
14 ; GCN-NEXT: s_getreg_b32 s0, hwreg(HW_REG_SH_MEM_BASES, 0, 16)
15 ; GCN-NEXT: v_mov_b32_e32 v2, 0
16 ; GCN-NEXT: s_lshl_b32 s0, s0, 16
17 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc_lo, -1, v0
18 ; GCN-NEXT: v_cndmask_b32_e64 v1, 0, s0, vcc_lo
19 ; GCN-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc_lo
20 ; GCN-NEXT: flat_store_dword v[0:1], v2
21 ; GCN-NEXT: s_waitcnt_vscnt null, 0x0
23 %alloca = alloca i32, addrspace(5)
24 %cast = addrspacecast i32 addrspace(5)* %alloca to i32*
25 store volatile i32 0, i32* %cast
29 define amdgpu_kernel void @stack_object_in_kernel_no_calls() {
30 ; GCN-LABEL: stack_object_in_kernel_no_calls:
32 ; GCN-NEXT: s_add_u32 s0, s0, s3
33 ; GCN-NEXT: s_addc_u32 s1, s1, 0
34 ; GCN-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s0
35 ; GCN-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s1
36 ; GCN-NEXT: v_mov_b32_e32 v0, 0
37 ; GCN-NEXT: s_mov_b32 vcc_lo, 0
38 ; GCN-NEXT: scratch_store_dword off, v0, vcc_lo offset:4
39 ; GCN-NEXT: s_waitcnt_vscnt null, 0x0
41 %alloca = alloca i32, addrspace(5)
42 store volatile i32 0, i32 addrspace(5)* %alloca
46 define amdgpu_kernel void @kernel_calls_no_stack() {
47 ; GCN-LABEL: kernel_calls_no_stack:
49 ; GCN-NEXT: s_add_u32 s0, s0, s3
50 ; GCN-NEXT: s_mov_b32 s32, 0
51 ; GCN-NEXT: s_addc_u32 s1, s1, 0
52 ; GCN-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s0
53 ; GCN-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s1
54 ; GCN-NEXT: s_getpc_b64 s[0:1]
55 ; GCN-NEXT: s_add_u32 s0, s0, extern_func@gotpcrel32@lo+4
56 ; GCN-NEXT: s_addc_u32 s1, s1, extern_func@gotpcrel32@hi+12
57 ; GCN-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
58 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
59 ; GCN-NEXT: s_swappc_b64 s[30:31], s[0:1]
61 call void @extern_func()
65 define amdgpu_kernel void @test(i32 addrspace(1)* %out, i32 %in) {
68 ; GCN-NEXT: s_add_u32 s2, s2, s5
69 ; GCN-NEXT: s_addc_u32 s3, s3, 0
70 ; GCN-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s2
71 ; GCN-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s3
72 ; GCN-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
73 ; GCN-NEXT: s_mov_b32 s104, exec_lo
74 ; GCN-NEXT: s_mov_b32 exec_lo, 3
75 ; GCN-NEXT: s_mov_b32 s105, 0
76 ; GCN-NEXT: scratch_store_dword off, v72, s105
77 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
78 ; GCN-NEXT: v_writelane_b32 v72, s2, 0
79 ; GCN-NEXT: s_mov_b32 s105, 4
80 ; GCN-NEXT: v_writelane_b32 v72, s3, 1
81 ; GCN-NEXT: scratch_store_dword off, v72, s105 ; 4-byte Folded Spill
82 ; GCN-NEXT: s_waitcnt_depctr 0xffe3
83 ; GCN-NEXT: s_mov_b32 s105, 0
84 ; GCN-NEXT: scratch_load_dword v72, off, s105
85 ; GCN-NEXT: s_waitcnt vmcnt(0)
86 ; GCN-NEXT: s_waitcnt_depctr 0xffe3
87 ; GCN-NEXT: s_mov_b32 exec_lo, s104
88 ; GCN-NEXT: s_load_dword vcc_lo, s[0:1], 0x8
89 ; GCN-NEXT: ; kill: killed $sgpr0_sgpr1
90 ; GCN-NEXT: ;;#ASMSTART
92 ; GCN-NEXT: ;;#ASMSTART
94 ; GCN-NEXT: ;;#ASMSTART
96 ; GCN-NEXT: ;;#ASMSTART
98 ; GCN-NEXT: ;;#ASMSTART
100 ; GCN-NEXT: ;;#ASMSTART
101 ; GCN-NEXT: ;;#ASMEND
102 ; GCN-NEXT: ;;#ASMSTART
103 ; GCN-NEXT: ;;#ASMEND
104 ; GCN-NEXT: ;;#ASMSTART
105 ; GCN-NEXT: ;;#ASMEND
106 ; GCN-NEXT: ;;#ASMSTART
107 ; GCN-NEXT: ;;#ASMEND
108 ; GCN-NEXT: ;;#ASMSTART
109 ; GCN-NEXT: ;;#ASMEND
110 ; GCN-NEXT: ;;#ASMSTART
111 ; GCN-NEXT: ;;#ASMEND
112 ; GCN-NEXT: ;;#ASMSTART
113 ; GCN-NEXT: ;;#ASMEND
114 ; GCN-NEXT: ;;#ASMSTART
115 ; GCN-NEXT: ;;#ASMEND
116 ; GCN-NEXT: ;;#ASMSTART
117 ; GCN-NEXT: ;;#ASMEND
118 ; GCN-NEXT: ;;#ASMSTART
119 ; GCN-NEXT: ;;#ASMEND
120 ; GCN-NEXT: ;;#ASMSTART
121 ; GCN-NEXT: ;;#ASMEND
122 ; GCN-NEXT: ;;#ASMSTART
123 ; GCN-NEXT: ;;#ASMEND
124 ; GCN-NEXT: ;;#ASMSTART
125 ; GCN-NEXT: ;;#ASMEND
126 ; GCN-NEXT: ;;#ASMSTART
127 ; GCN-NEXT: ;;#ASMEND
128 ; GCN-NEXT: ;;#ASMSTART
129 ; GCN-NEXT: ;;#ASMEND
130 ; GCN-NEXT: ;;#ASMSTART
131 ; GCN-NEXT: ;;#ASMEND
132 ; GCN-NEXT: ;;#ASMSTART
133 ; GCN-NEXT: ;;#ASMEND
134 ; GCN-NEXT: ;;#ASMSTART
135 ; GCN-NEXT: ;;#ASMEND
136 ; GCN-NEXT: ;;#ASMSTART
137 ; GCN-NEXT: ;;#ASMEND
138 ; GCN-NEXT: ;;#ASMSTART
139 ; GCN-NEXT: ;;#ASMEND
140 ; GCN-NEXT: ;;#ASMSTART
141 ; GCN-NEXT: ;;#ASMEND
142 ; GCN-NEXT: ;;#ASMSTART
143 ; GCN-NEXT: ;;#ASMEND
144 ; GCN-NEXT: ;;#ASMSTART
145 ; GCN-NEXT: ;;#ASMEND
146 ; GCN-NEXT: ;;#ASMSTART
147 ; GCN-NEXT: ;;#ASMEND
148 ; GCN-NEXT: ;;#ASMSTART
149 ; GCN-NEXT: ;;#ASMEND
150 ; GCN-NEXT: ;;#ASMSTART
151 ; GCN-NEXT: ;;#ASMEND
152 ; GCN-NEXT: ;;#ASMSTART
153 ; GCN-NEXT: ;;#ASMEND
154 ; GCN-NEXT: ;;#ASMSTART
155 ; GCN-NEXT: ;;#ASMEND
156 ; GCN-NEXT: ;;#ASMSTART
157 ; GCN-NEXT: ;;#ASMEND
158 ; GCN-NEXT: ;;#ASMSTART
159 ; GCN-NEXT: ;;#ASMEND
160 ; GCN-NEXT: ;;#ASMSTART
161 ; GCN-NEXT: ;;#ASMEND
162 ; GCN-NEXT: ;;#ASMSTART
163 ; GCN-NEXT: ;;#ASMEND
164 ; GCN-NEXT: ;;#ASMSTART
165 ; GCN-NEXT: ;;#ASMEND
166 ; GCN-NEXT: ;;#ASMSTART
167 ; GCN-NEXT: ;;#ASMEND
168 ; GCN-NEXT: ;;#ASMSTART
169 ; GCN-NEXT: ;;#ASMEND
170 ; GCN-NEXT: ;;#ASMSTART
171 ; GCN-NEXT: ;;#ASMEND
172 ; GCN-NEXT: ;;#ASMSTART
173 ; GCN-NEXT: ;;#ASMEND
174 ; GCN-NEXT: ;;#ASMSTART
175 ; GCN-NEXT: ;;#ASMEND
176 ; GCN-NEXT: ;;#ASMSTART
177 ; GCN-NEXT: ;;#ASMEND
178 ; GCN-NEXT: ;;#ASMSTART
179 ; GCN-NEXT: ;;#ASMEND
180 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
181 ; GCN-NEXT: v_mov_b32_e32 v0, vcc_lo
182 ; GCN-NEXT: ;;#ASMSTART
183 ; GCN-NEXT: ;;#ASMEND
184 ; GCN-NEXT: s_mov_b32 s2, exec_lo
185 ; GCN-NEXT: s_mov_b32 exec_lo, 3
186 ; GCN-NEXT: s_mov_b32 s3, 0
187 ; GCN-NEXT: scratch_store_dword off, v2, s3
188 ; GCN-NEXT: s_waitcnt_depctr 0xffe3
189 ; GCN-NEXT: s_mov_b32 s3, 4
190 ; GCN-NEXT: scratch_load_dword v2, off, s3 ; 4-byte Folded Reload
191 ; GCN-NEXT: s_waitcnt_depctr 0xffe3
192 ; GCN-NEXT: s_mov_b32 s3, 0
193 ; GCN-NEXT: s_waitcnt vmcnt(0)
194 ; GCN-NEXT: v_readlane_b32 s0, v2, 0
195 ; GCN-NEXT: v_readlane_b32 s1, v2, 1
196 ; GCN-NEXT: scratch_load_dword v2, off, s3
197 ; GCN-NEXT: s_waitcnt vmcnt(0)
198 ; GCN-NEXT: s_waitcnt_depctr 0xffe3
199 ; GCN-NEXT: s_mov_b32 exec_lo, s2
200 ; GCN-NEXT: v_mov_b32_e32 v1, 0
201 ; GCN-NEXT: global_store_dword v1, v0, s[0:1]
203 call void asm sideeffect "", "~{s[0:7]}" ()
204 call void asm sideeffect "", "~{s[8:15]}" ()
205 call void asm sideeffect "", "~{s[16:23]}" ()
206 call void asm sideeffect "", "~{s[24:31]}" ()
207 call void asm sideeffect "", "~{s[32:39]}" ()
208 call void asm sideeffect "", "~{s[40:47]}" ()
209 call void asm sideeffect "", "~{s[48:55]}" ()
210 call void asm sideeffect "", "~{s[56:63]}" ()
211 call void asm sideeffect "", "~{s[64:71]}" ()
212 call void asm sideeffect "", "~{s[72:79]}" ()
213 call void asm sideeffect "", "~{s[80:87]}" ()
214 call void asm sideeffect "", "~{s[88:95]}" ()
215 call void asm sideeffect "", "~{s[96:103]}" ()
216 call void asm sideeffect "", "~{s[104:105]}" ()
217 call void asm sideeffect "", "~{v[0:7]}" ()
218 call void asm sideeffect "", "~{v[8:15]}" ()
219 call void asm sideeffect "", "~{v[16:23]}" ()
220 call void asm sideeffect "", "~{v[24:31]}" ()
221 call void asm sideeffect "", "~{v[32:39]}" ()
222 call void asm sideeffect "", "~{v[40:47]}" ()
223 call void asm sideeffect "", "~{v[48:55]}" ()
224 call void asm sideeffect "", "~{v[56:63]}" ()
225 call void asm sideeffect "", "~{v[64:71]}" ()
226 call void asm sideeffect "", "~{v[72:79]}" ()
227 call void asm sideeffect "", "~{v[80:87]}" ()
228 call void asm sideeffect "", "~{v[88:95]}" ()
229 call void asm sideeffect "", "~{v[96:103]}" ()
230 call void asm sideeffect "", "~{v[104:111]}" ()
231 call void asm sideeffect "", "~{v[112:119]}" ()
232 call void asm sideeffect "", "~{v[120:127]}" ()
233 call void asm sideeffect "", "~{v[128:135]}" ()
234 call void asm sideeffect "", "~{v[136:143]}" ()
235 call void asm sideeffect "", "~{v[144:151]}" ()
236 call void asm sideeffect "", "~{v[152:159]}" ()
237 call void asm sideeffect "", "~{v[160:167]}" ()
238 call void asm sideeffect "", "~{v[168:175]}" ()
239 call void asm sideeffect "", "~{v[176:183]}" ()
240 call void asm sideeffect "", "~{v[184:191]}" ()
241 call void asm sideeffect "", "~{v[192:199]}" ()
242 call void asm sideeffect "", "~{v[200:207]}" ()
243 call void asm sideeffect "", "~{v[208:215]}" ()
244 call void asm sideeffect "", "~{v[216:223]}" ()
245 call void asm sideeffect "", "~{v[224:231]}" ()
246 call void asm sideeffect "", "~{v[232:239]}" ()
247 call void asm sideeffect "", "~{v[240:247]}" ()
248 call void asm sideeffect "", "~{v[248:255]}" ()
250 store i32 %in, i32 addrspace(1)* %out
254 define amdgpu_kernel void @kernel_no_calls_no_stack() {
255 ; GCN-LABEL: kernel_no_calls_no_stack:
261 attributes #0 = { nounwind }