1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs -amdgpu-remove-redundant-endcf -amdgpu-codegenprepare-break-large-phis=0 < %s | FileCheck -enable-var-scope -check-prefix=GCN %s
4 ; Disabled endcf collapse at -O0.
5 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs -O0 -amdgpu-remove-redundant-endcf -amdgpu-codegenprepare-break-large-phis=0 < %s | FileCheck -enable-var-scope -check-prefix=GCN-O0 %s
7 ; Note: Breaking large PHIs is disabled to branches from being eliminated (in scc_liveness)
9 define amdgpu_kernel void @simple_nested_if(ptr addrspace(1) nocapture %arg) {
10 ; GCN-LABEL: simple_nested_if:
12 ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, 1, v0
13 ; GCN-NEXT: s_and_saveexec_b64 s[4:5], vcc
14 ; GCN-NEXT: s_cbranch_execz .LBB0_3
15 ; GCN-NEXT: ; %bb.1: ; %bb.outer.then
16 ; GCN-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x9
17 ; GCN-NEXT: v_lshlrev_b32_e32 v1, 2, v0
18 ; GCN-NEXT: v_mov_b32_e32 v2, 0
19 ; GCN-NEXT: s_mov_b32 s3, 0xf000
20 ; GCN-NEXT: s_mov_b32 s2, 0
21 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 2, v0
22 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
23 ; GCN-NEXT: buffer_store_dword v2, v[1:2], s[0:3], 0 addr64
24 ; GCN-NEXT: s_and_b64 exec, exec, vcc
25 ; GCN-NEXT: s_cbranch_execz .LBB0_3
26 ; GCN-NEXT: ; %bb.2: ; %bb.inner.then
27 ; GCN-NEXT: s_waitcnt expcnt(0)
28 ; GCN-NEXT: v_mov_b32_e32 v2, s1
29 ; GCN-NEXT: v_add_i32_e32 v0, vcc, s0, v1
30 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
31 ; GCN-NEXT: s_mov_b32 s0, s2
32 ; GCN-NEXT: s_mov_b32 s1, s2
33 ; GCN-NEXT: v_mov_b32_e32 v2, 1
34 ; GCN-NEXT: buffer_store_dword v2, v[0:1], s[0:3], 0 addr64 offset:4
35 ; GCN-NEXT: .LBB0_3: ; %bb.outer.end
36 ; GCN-NEXT: s_or_b64 exec, exec, s[4:5]
37 ; GCN-NEXT: v_mov_b32_e32 v0, 3
38 ; GCN-NEXT: v_mov_b32_e32 v1, 0
39 ; GCN-NEXT: s_mov_b32 m0, -1
40 ; GCN-NEXT: ds_write_b32 v1, v0
43 ; GCN-O0-LABEL: simple_nested_if:
44 ; GCN-O0: ; %bb.0: ; %bb
45 ; GCN-O0-NEXT: s_mov_b32 s12, SCRATCH_RSRC_DWORD0
46 ; GCN-O0-NEXT: s_mov_b32 s13, SCRATCH_RSRC_DWORD1
47 ; GCN-O0-NEXT: s_mov_b32 s14, -1
48 ; GCN-O0-NEXT: s_mov_b32 s15, 0xe8f000
49 ; GCN-O0-NEXT: s_add_u32 s12, s12, s11
50 ; GCN-O0-NEXT: s_addc_u32 s13, s13, 0
51 ; GCN-O0-NEXT: ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
52 ; GCN-O0-NEXT: v_mov_b32_e32 v1, v0
53 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
54 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
55 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
56 ; GCN-O0-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x9
57 ; GCN-O0-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
58 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 0
59 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 1
60 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v1
61 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[12:15], 0 offset:8 ; 4-byte Folded Spill
62 ; GCN-O0-NEXT: s_mov_b32 s0, 1
63 ; GCN-O0-NEXT: v_cmp_gt_u32_e64 s[2:3], v1, s0
64 ; GCN-O0-NEXT: s_mov_b64 s[0:1], exec
65 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 2
66 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 3
67 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
68 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
69 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
70 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[0:1], s[2:3]
71 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
72 ; GCN-O0-NEXT: s_cbranch_execz .LBB0_4
73 ; GCN-O0-NEXT: ; %bb.1: ; %bb.outer.then
74 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
75 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
76 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
77 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
78 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
79 ; GCN-O0-NEXT: v_readlane_b32 s4, v0, 0
80 ; GCN-O0-NEXT: v_readlane_b32 s5, v0, 1
81 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
82 ; GCN-O0-NEXT: s_mov_b32 s2, 0xf000
83 ; GCN-O0-NEXT: s_mov_b32 s0, 0
84 ; GCN-O0-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
85 ; GCN-O0-NEXT: s_mov_b32 s1, s2
86 ; GCN-O0-NEXT: ; kill: def $sgpr4_sgpr5 killed $sgpr4_sgpr5 def $sgpr4_sgpr5_sgpr6_sgpr7
87 ; GCN-O0-NEXT: s_mov_b64 s[6:7], s[0:1]
88 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
89 ; GCN-O0-NEXT: v_ashrrev_i32_e64 v4, 31, v1
90 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v1
91 ; GCN-O0-NEXT: v_mov_b32_e32 v3, v4
92 ; GCN-O0-NEXT: s_mov_b32 s0, 2
93 ; GCN-O0-NEXT: v_lshl_b64 v[3:4], v[2:3], s0
94 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 0
95 ; GCN-O0-NEXT: buffer_store_dword v2, v[3:4], s[4:7], 0 addr64
96 ; GCN-O0-NEXT: v_cmp_ne_u32_e64 s[2:3], v1, s0
97 ; GCN-O0-NEXT: s_mov_b64 s[0:1], exec
98 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 4
99 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 5
100 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
101 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
102 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
103 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[0:1], s[2:3]
104 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
105 ; GCN-O0-NEXT: s_cbranch_execz .LBB0_3
106 ; GCN-O0-NEXT: ; %bb.2: ; %bb.inner.then
107 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
108 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
109 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
110 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
111 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
112 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 0
113 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 1
114 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
115 ; GCN-O0-NEXT: v_mov_b32_e32 v0, 1
116 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
117 ; GCN-O0-NEXT: v_add_i32_e64 v1, s[2:3], v1, v0
118 ; GCN-O0-NEXT: v_ashrrev_i32_e64 v3, 31, v1
119 ; GCN-O0-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
120 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v3
121 ; GCN-O0-NEXT: s_mov_b32 s2, 2
122 ; GCN-O0-NEXT: v_lshl_b64 v[1:2], v[1:2], s2
123 ; GCN-O0-NEXT: s_mov_b32 s2, 0xf000
124 ; GCN-O0-NEXT: s_mov_b32 s4, 0
125 ; GCN-O0-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
126 ; GCN-O0-NEXT: s_mov_b32 s5, s2
127 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
128 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
129 ; GCN-O0-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64
130 ; GCN-O0-NEXT: .LBB0_3: ; %Flow
131 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
132 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
133 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
134 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
135 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
136 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 4
137 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 5
138 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[0:1]
139 ; GCN-O0-NEXT: .LBB0_4: ; %bb.outer.end
140 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
141 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
142 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
143 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
144 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
145 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 2
146 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 3
147 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[0:1]
148 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 3
149 ; GCN-O0-NEXT: v_mov_b32_e32 v1, 0
150 ; GCN-O0-NEXT: s_mov_b32 m0, -1
151 ; GCN-O0-NEXT: ds_write_b32 v1, v2
152 ; GCN-O0-NEXT: ; kill: killed $vgpr0
153 ; GCN-O0-NEXT: s_endpgm
155 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x()
156 %tmp1 = icmp ugt i32 %tmp, 1
157 br i1 %tmp1, label %bb.outer.then, label %bb.outer.end
159 bb.outer.then: ; preds = %bb
160 %tmp4 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp
161 store i32 0, ptr addrspace(1) %tmp4, align 4
162 %tmp5 = icmp eq i32 %tmp, 2
163 br i1 %tmp5, label %bb.outer.end, label %bb.inner.then
165 bb.inner.then: ; preds = %bb.outer.then
166 %tmp7 = add i32 %tmp, 1
167 %tmp9 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp7
168 store i32 1, ptr addrspace(1) %tmp9, align 4
169 br label %bb.outer.end
171 bb.outer.end: ; preds = %bb.outer.then, %bb.inner.then, %bb
172 store i32 3, ptr addrspace(3) null
176 define amdgpu_kernel void @uncollapsable_nested_if(ptr addrspace(1) nocapture %arg) {
177 ; GCN-LABEL: uncollapsable_nested_if:
178 ; GCN: ; %bb.0: ; %bb
179 ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, 1, v0
180 ; GCN-NEXT: s_and_saveexec_b64 s[4:5], vcc
181 ; GCN-NEXT: s_cbranch_execz .LBB1_4
182 ; GCN-NEXT: ; %bb.1: ; %bb.outer.then
183 ; GCN-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x9
184 ; GCN-NEXT: v_lshlrev_b32_e32 v3, 2, v0
185 ; GCN-NEXT: v_mov_b32_e32 v4, 0
186 ; GCN-NEXT: s_mov_b32 s3, 0xf000
187 ; GCN-NEXT: s_mov_b32 s2, 0
188 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
189 ; GCN-NEXT: v_mov_b32_e32 v2, s1
190 ; GCN-NEXT: v_add_i32_e32 v1, vcc, s0, v3
191 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v2, vcc
192 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 2, v0
193 ; GCN-NEXT: buffer_store_dword v4, v[3:4], s[0:3], 0 addr64
194 ; GCN-NEXT: s_and_saveexec_b64 s[6:7], vcc
195 ; GCN-NEXT: s_cbranch_execz .LBB1_3
196 ; GCN-NEXT: ; %bb.2: ; %bb.inner.then
197 ; GCN-NEXT: s_mov_b32 s0, s2
198 ; GCN-NEXT: s_mov_b32 s1, s2
199 ; GCN-NEXT: v_mov_b32_e32 v0, 1
200 ; GCN-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64 offset:4
201 ; GCN-NEXT: .LBB1_3: ; %bb.inner.end
202 ; GCN-NEXT: s_or_b64 exec, exec, s[6:7]
203 ; GCN-NEXT: s_mov_b32 s0, s2
204 ; GCN-NEXT: s_mov_b32 s1, s2
205 ; GCN-NEXT: s_waitcnt expcnt(0)
206 ; GCN-NEXT: v_mov_b32_e32 v0, 2
207 ; GCN-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64 offset:8
208 ; GCN-NEXT: .LBB1_4: ; %Flow
209 ; GCN-NEXT: s_or_b64 exec, exec, s[4:5]
210 ; GCN-NEXT: s_waitcnt expcnt(0)
211 ; GCN-NEXT: v_mov_b32_e32 v0, 3
212 ; GCN-NEXT: v_mov_b32_e32 v1, 0
213 ; GCN-NEXT: s_mov_b32 m0, -1
214 ; GCN-NEXT: ds_write_b32 v1, v0
217 ; GCN-O0-LABEL: uncollapsable_nested_if:
218 ; GCN-O0: ; %bb.0: ; %bb
219 ; GCN-O0-NEXT: s_mov_b32 s12, SCRATCH_RSRC_DWORD0
220 ; GCN-O0-NEXT: s_mov_b32 s13, SCRATCH_RSRC_DWORD1
221 ; GCN-O0-NEXT: s_mov_b32 s14, -1
222 ; GCN-O0-NEXT: s_mov_b32 s15, 0xe8f000
223 ; GCN-O0-NEXT: s_add_u32 s12, s12, s11
224 ; GCN-O0-NEXT: s_addc_u32 s13, s13, 0
225 ; GCN-O0-NEXT: ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
226 ; GCN-O0-NEXT: v_mov_b32_e32 v1, v0
227 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
228 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
229 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
230 ; GCN-O0-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x9
231 ; GCN-O0-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
232 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 0
233 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 1
234 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v1
235 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[12:15], 0 offset:8 ; 4-byte Folded Spill
236 ; GCN-O0-NEXT: s_mov_b32 s0, 1
237 ; GCN-O0-NEXT: v_cmp_gt_u32_e64 s[2:3], v1, s0
238 ; GCN-O0-NEXT: s_mov_b64 s[0:1], exec
239 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 2
240 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 3
241 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
242 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
243 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
244 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[0:1], s[2:3]
245 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
246 ; GCN-O0-NEXT: s_cbranch_execz .LBB1_3
247 ; GCN-O0-NEXT: ; %bb.1: ; %bb.outer.then
248 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
249 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
250 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
251 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
252 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
253 ; GCN-O0-NEXT: v_readlane_b32 s4, v0, 0
254 ; GCN-O0-NEXT: v_readlane_b32 s5, v0, 1
255 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
256 ; GCN-O0-NEXT: s_mov_b32 s2, 0xf000
257 ; GCN-O0-NEXT: s_mov_b32 s0, 0
258 ; GCN-O0-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
259 ; GCN-O0-NEXT: s_mov_b32 s1, s2
260 ; GCN-O0-NEXT: ; kill: def $sgpr4_sgpr5 killed $sgpr4_sgpr5 def $sgpr4_sgpr5_sgpr6_sgpr7
261 ; GCN-O0-NEXT: s_mov_b64 s[6:7], s[0:1]
262 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
263 ; GCN-O0-NEXT: v_ashrrev_i32_e64 v4, 31, v1
264 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v1
265 ; GCN-O0-NEXT: v_mov_b32_e32 v3, v4
266 ; GCN-O0-NEXT: s_mov_b32 s0, 2
267 ; GCN-O0-NEXT: v_lshl_b64 v[3:4], v[2:3], s0
268 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 0
269 ; GCN-O0-NEXT: buffer_store_dword v2, v[3:4], s[4:7], 0 addr64
270 ; GCN-O0-NEXT: v_cmp_ne_u32_e64 s[2:3], v1, s0
271 ; GCN-O0-NEXT: s_mov_b64 s[0:1], exec
272 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 4
273 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 5
274 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
275 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
276 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
277 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[0:1], s[2:3]
278 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
279 ; GCN-O0-NEXT: s_cbranch_execz .LBB1_4
280 ; GCN-O0-NEXT: ; %bb.2: ; %bb.inner.then
281 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
282 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
283 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
284 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
285 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
286 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 0
287 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 1
288 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
289 ; GCN-O0-NEXT: v_mov_b32_e32 v0, 1
290 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
291 ; GCN-O0-NEXT: v_add_i32_e64 v1, s[2:3], v1, v0
292 ; GCN-O0-NEXT: v_ashrrev_i32_e64 v3, 31, v1
293 ; GCN-O0-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
294 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v3
295 ; GCN-O0-NEXT: s_mov_b32 s2, 2
296 ; GCN-O0-NEXT: v_lshl_b64 v[1:2], v[1:2], s2
297 ; GCN-O0-NEXT: s_mov_b32 s2, 0xf000
298 ; GCN-O0-NEXT: s_mov_b32 s4, 0
299 ; GCN-O0-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
300 ; GCN-O0-NEXT: s_mov_b32 s5, s2
301 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
302 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
303 ; GCN-O0-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64
304 ; GCN-O0-NEXT: s_branch .LBB1_4
305 ; GCN-O0-NEXT: .LBB1_3: ; %Flow
306 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
307 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
308 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
309 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
310 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
311 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 2
312 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 3
313 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[0:1]
314 ; GCN-O0-NEXT: s_branch .LBB1_5
315 ; GCN-O0-NEXT: .LBB1_4: ; %bb.inner.end
316 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
317 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
318 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
319 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
320 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
321 ; GCN-O0-NEXT: v_readlane_b32 s2, v0, 4
322 ; GCN-O0-NEXT: v_readlane_b32 s3, v0, 5
323 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[2:3]
324 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 0
325 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 1
326 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
327 ; GCN-O0-NEXT: v_mov_b32_e32 v0, 2
328 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
329 ; GCN-O0-NEXT: v_add_i32_e64 v1, s[2:3], v1, v0
330 ; GCN-O0-NEXT: v_ashrrev_i32_e64 v3, 31, v1
331 ; GCN-O0-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
332 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v3
333 ; GCN-O0-NEXT: v_lshl_b64 v[1:2], v[1:2], v0
334 ; GCN-O0-NEXT: s_mov_b32 s2, 0xf000
335 ; GCN-O0-NEXT: s_mov_b32 s4, 0
336 ; GCN-O0-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
337 ; GCN-O0-NEXT: s_mov_b32 s5, s2
338 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
339 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
340 ; GCN-O0-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64
341 ; GCN-O0-NEXT: s_branch .LBB1_3
342 ; GCN-O0-NEXT: .LBB1_5: ; %bb.outer.end
343 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
344 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
345 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
346 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 3
347 ; GCN-O0-NEXT: v_mov_b32_e32 v1, 0
348 ; GCN-O0-NEXT: s_mov_b32 m0, -1
349 ; GCN-O0-NEXT: ds_write_b32 v1, v2
350 ; GCN-O0-NEXT: ; kill: killed $vgpr0
351 ; GCN-O0-NEXT: s_endpgm
353 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x()
354 %tmp1 = icmp ugt i32 %tmp, 1
355 br i1 %tmp1, label %bb.outer.then, label %bb.outer.end
357 bb.outer.then: ; preds = %bb
358 %tmp4 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp
359 store i32 0, ptr addrspace(1) %tmp4, align 4
360 %tmp5 = icmp eq i32 %tmp, 2
361 br i1 %tmp5, label %bb.inner.end, label %bb.inner.then
363 bb.inner.then: ; preds = %bb.outer.then
364 %tmp7 = add i32 %tmp, 1
365 %tmp8 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp7
366 store i32 1, ptr addrspace(1) %tmp8, align 4
367 br label %bb.inner.end
369 bb.inner.end: ; preds = %bb.inner.then, %bb.outer.then
370 %tmp9 = add i32 %tmp, 2
371 %tmp10 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp9
372 store i32 2, ptr addrspace(1) %tmp10, align 4
373 br label %bb.outer.end
375 bb.outer.end: ; preds = %bb.inner.then, %bb
376 store i32 3, ptr addrspace(3) null
380 define amdgpu_kernel void @nested_if_if_else(ptr addrspace(1) nocapture %arg) {
381 ; GCN-LABEL: nested_if_if_else:
382 ; GCN: ; %bb.0: ; %bb
383 ; GCN-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x9
384 ; GCN-NEXT: v_lshlrev_b32_e32 v1, 2, v0
385 ; GCN-NEXT: v_mov_b32_e32 v2, 0
386 ; GCN-NEXT: s_mov_b32 s3, 0xf000
387 ; GCN-NEXT: s_mov_b32 s2, 0
388 ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, 1, v0
389 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
390 ; GCN-NEXT: buffer_store_dword v2, v[1:2], s[0:3], 0 addr64
391 ; GCN-NEXT: s_and_saveexec_b64 s[2:3], vcc
392 ; GCN-NEXT: s_cbranch_execz .LBB2_5
393 ; GCN-NEXT: ; %bb.1: ; %bb.outer.then
394 ; GCN-NEXT: v_mov_b32_e32 v4, s1
395 ; GCN-NEXT: v_add_i32_e32 v3, vcc, s0, v1
396 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v4, vcc
397 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 2, v0
398 ; GCN-NEXT: s_and_saveexec_b64 s[0:1], vcc
399 ; GCN-NEXT: s_xor_b64 s[0:1], exec, s[0:1]
400 ; GCN-NEXT: s_cbranch_execz .LBB2_3
401 ; GCN-NEXT: ; %bb.2: ; %bb.else
402 ; GCN-NEXT: s_mov_b32 s6, 0
403 ; GCN-NEXT: s_mov_b32 s7, 0xf000
404 ; GCN-NEXT: s_mov_b32 s4, s6
405 ; GCN-NEXT: s_mov_b32 s5, s6
406 ; GCN-NEXT: v_mov_b32_e32 v0, 2
407 ; GCN-NEXT: buffer_store_dword v0, v[3:4], s[4:7], 0 addr64 offset:8
408 ; GCN-NEXT: ; implicit-def: $vgpr3_vgpr4
409 ; GCN-NEXT: .LBB2_3: ; %Flow
410 ; GCN-NEXT: s_andn2_saveexec_b64 s[0:1], s[0:1]
411 ; GCN-NEXT: s_cbranch_execz .LBB2_5
412 ; GCN-NEXT: ; %bb.4: ; %bb.then
413 ; GCN-NEXT: s_mov_b32 s6, 0
414 ; GCN-NEXT: s_mov_b32 s7, 0xf000
415 ; GCN-NEXT: s_mov_b32 s4, s6
416 ; GCN-NEXT: s_mov_b32 s5, s6
417 ; GCN-NEXT: s_waitcnt expcnt(0)
418 ; GCN-NEXT: v_mov_b32_e32 v0, 1
419 ; GCN-NEXT: buffer_store_dword v0, v[3:4], s[4:7], 0 addr64 offset:4
420 ; GCN-NEXT: .LBB2_5: ; %bb.outer.end
421 ; GCN-NEXT: s_or_b64 exec, exec, s[2:3]
422 ; GCN-NEXT: s_waitcnt expcnt(0)
423 ; GCN-NEXT: v_mov_b32_e32 v0, 3
424 ; GCN-NEXT: s_mov_b32 m0, -1
425 ; GCN-NEXT: ds_write_b32 v2, v0
428 ; GCN-O0-LABEL: nested_if_if_else:
429 ; GCN-O0: ; %bb.0: ; %bb
430 ; GCN-O0-NEXT: s_mov_b32 s12, SCRATCH_RSRC_DWORD0
431 ; GCN-O0-NEXT: s_mov_b32 s13, SCRATCH_RSRC_DWORD1
432 ; GCN-O0-NEXT: s_mov_b32 s14, -1
433 ; GCN-O0-NEXT: s_mov_b32 s15, 0xe8f000
434 ; GCN-O0-NEXT: s_add_u32 s12, s12, s11
435 ; GCN-O0-NEXT: s_addc_u32 s13, s13, 0
436 ; GCN-O0-NEXT: ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
437 ; GCN-O0-NEXT: v_mov_b32_e32 v1, v0
438 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
439 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
440 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
441 ; GCN-O0-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x9
442 ; GCN-O0-NEXT: s_waitcnt lgkmcnt(0)
443 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[0:1]
444 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
445 ; GCN-O0-NEXT: v_writelane_b32 v0, s2, 0
446 ; GCN-O0-NEXT: v_writelane_b32 v0, s3, 1
447 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v1
448 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[12:15], 0 offset:8 ; 4-byte Folded Spill
449 ; GCN-O0-NEXT: s_mov_b32 s2, 0xf000
450 ; GCN-O0-NEXT: s_mov_b32 s4, 0
451 ; GCN-O0-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
452 ; GCN-O0-NEXT: s_mov_b32 s5, s2
453 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
454 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
455 ; GCN-O0-NEXT: s_mov_b32 s4, 2
456 ; GCN-O0-NEXT: v_lshlrev_b32_e64 v3, s4, v1
457 ; GCN-O0-NEXT: s_mov_b32 s4, 0
458 ; GCN-O0-NEXT: ; implicit-def: $sgpr4
459 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
460 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 0
461 ; GCN-O0-NEXT: ; kill: def $vgpr3 killed $vgpr3 def $vgpr3_vgpr4 killed $exec
462 ; GCN-O0-NEXT: v_mov_b32_e32 v4, v2
463 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 0
464 ; GCN-O0-NEXT: buffer_store_dword v2, v[3:4], s[0:3], 0 addr64
465 ; GCN-O0-NEXT: s_mov_b32 s0, 1
466 ; GCN-O0-NEXT: v_cmp_gt_u32_e64 s[2:3], v1, s0
467 ; GCN-O0-NEXT: s_mov_b64 s[0:1], exec
468 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 2
469 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 3
470 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
471 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
472 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
473 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[0:1], s[2:3]
474 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
475 ; GCN-O0-NEXT: s_cbranch_execz .LBB2_6
476 ; GCN-O0-NEXT: ; %bb.1: ; %bb.outer.then
477 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
478 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
479 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
480 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
481 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
482 ; GCN-O0-NEXT: s_mov_b32 s0, 2
483 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
484 ; GCN-O0-NEXT: v_cmp_ne_u32_e64 s[0:1], v1, s0
485 ; GCN-O0-NEXT: s_mov_b64 s[2:3], exec
486 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[2:3], s[0:1]
487 ; GCN-O0-NEXT: s_xor_b64 s[2:3], s[0:1], s[2:3]
488 ; GCN-O0-NEXT: v_writelane_b32 v0, s2, 4
489 ; GCN-O0-NEXT: v_writelane_b32 v0, s3, 5
490 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
491 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
492 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
493 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
494 ; GCN-O0-NEXT: s_cbranch_execz .LBB2_2
495 ; GCN-O0-NEXT: s_branch .LBB2_4
496 ; GCN-O0-NEXT: .LBB2_2: ; %Flow
497 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
498 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
499 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
500 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
501 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
502 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 4
503 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 5
504 ; GCN-O0-NEXT: s_or_saveexec_b64 s[0:1], s[0:1]
505 ; GCN-O0-NEXT: s_and_b64 s[0:1], exec, s[0:1]
506 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 6
507 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 7
508 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
509 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
510 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
511 ; GCN-O0-NEXT: s_xor_b64 exec, exec, s[0:1]
512 ; GCN-O0-NEXT: s_cbranch_execz .LBB2_5
513 ; GCN-O0-NEXT: ; %bb.3: ; %bb.then
514 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
515 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
516 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
517 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
518 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
519 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 0
520 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 1
521 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
522 ; GCN-O0-NEXT: v_mov_b32_e32 v0, 1
523 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
524 ; GCN-O0-NEXT: v_add_i32_e64 v1, s[2:3], v1, v0
525 ; GCN-O0-NEXT: v_ashrrev_i32_e64 v3, 31, v1
526 ; GCN-O0-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
527 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v3
528 ; GCN-O0-NEXT: s_mov_b32 s2, 2
529 ; GCN-O0-NEXT: v_lshl_b64 v[1:2], v[1:2], s2
530 ; GCN-O0-NEXT: s_mov_b32 s2, 0xf000
531 ; GCN-O0-NEXT: s_mov_b32 s4, 0
532 ; GCN-O0-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
533 ; GCN-O0-NEXT: s_mov_b32 s5, s2
534 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
535 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
536 ; GCN-O0-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64
537 ; GCN-O0-NEXT: s_branch .LBB2_5
538 ; GCN-O0-NEXT: .LBB2_4: ; %bb.else
539 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
540 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
541 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
542 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
543 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
544 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 0
545 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 1
546 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
547 ; GCN-O0-NEXT: v_mov_b32_e32 v0, 2
548 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
549 ; GCN-O0-NEXT: v_add_i32_e64 v1, s[2:3], v1, v0
550 ; GCN-O0-NEXT: v_ashrrev_i32_e64 v3, 31, v1
551 ; GCN-O0-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
552 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v3
553 ; GCN-O0-NEXT: v_lshl_b64 v[1:2], v[1:2], v0
554 ; GCN-O0-NEXT: s_mov_b32 s2, 0xf000
555 ; GCN-O0-NEXT: s_mov_b32 s4, 0
556 ; GCN-O0-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
557 ; GCN-O0-NEXT: s_mov_b32 s5, s2
558 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
559 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
560 ; GCN-O0-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64
561 ; GCN-O0-NEXT: s_branch .LBB2_2
562 ; GCN-O0-NEXT: .LBB2_5: ; %Flow1
563 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
564 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
565 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
566 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
567 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
568 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 6
569 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 7
570 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[0:1]
571 ; GCN-O0-NEXT: .LBB2_6: ; %bb.outer.end
572 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
573 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
574 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
575 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
576 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
577 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 2
578 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 3
579 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[0:1]
580 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 3
581 ; GCN-O0-NEXT: v_mov_b32_e32 v1, 0
582 ; GCN-O0-NEXT: s_mov_b32 m0, -1
583 ; GCN-O0-NEXT: ds_write_b32 v1, v2
584 ; GCN-O0-NEXT: ; kill: killed $vgpr0
585 ; GCN-O0-NEXT: s_endpgm
587 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x()
588 %tmp1 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp
589 store i32 0, ptr addrspace(1) %tmp1, align 4
590 %tmp2 = icmp ugt i32 %tmp, 1
591 br i1 %tmp2, label %bb.outer.then, label %bb.outer.end
593 bb.outer.then: ; preds = %bb
594 %tmp5 = icmp eq i32 %tmp, 2
595 br i1 %tmp5, label %bb.then, label %bb.else
597 bb.then: ; preds = %bb.outer.then
598 %tmp3 = add i32 %tmp, 1
599 %tmp4 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp3
600 store i32 1, ptr addrspace(1) %tmp4, align 4
601 br label %bb.outer.end
603 bb.else: ; preds = %bb.outer.then
604 %tmp7 = add i32 %tmp, 2
605 %tmp9 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp7
606 store i32 2, ptr addrspace(1) %tmp9, align 4
607 br label %bb.outer.end
609 bb.outer.end: ; preds = %bb, %bb.then, %bb.else
610 store i32 3, ptr addrspace(3) null
614 define amdgpu_kernel void @nested_if_else_if(ptr addrspace(1) nocapture %arg) {
615 ; GCN-LABEL: nested_if_else_if:
616 ; GCN: ; %bb.0: ; %bb
617 ; GCN-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x9
618 ; GCN-NEXT: v_lshlrev_b32_e32 v3, 2, v0
619 ; GCN-NEXT: v_mov_b32_e32 v4, 0
620 ; GCN-NEXT: s_mov_b32 s3, 0xf000
621 ; GCN-NEXT: s_mov_b32 s2, 0
622 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
623 ; GCN-NEXT: v_mov_b32_e32 v2, s1
624 ; GCN-NEXT: v_add_i32_e32 v1, vcc, s0, v3
625 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v2, vcc
626 ; GCN-NEXT: v_cmp_gt_u32_e32 vcc, 2, v0
627 ; GCN-NEXT: buffer_store_dword v4, v[3:4], s[0:3], 0 addr64
628 ; GCN-NEXT: s_and_saveexec_b64 s[0:1], vcc
629 ; GCN-NEXT: s_xor_b64 s[4:5], exec, s[0:1]
630 ; GCN-NEXT: s_cbranch_execz .LBB3_4
631 ; GCN-NEXT: ; %bb.1: ; %bb.outer.else
632 ; GCN-NEXT: s_mov_b32 s0, s2
633 ; GCN-NEXT: s_mov_b32 s1, s2
634 ; GCN-NEXT: v_mov_b32_e32 v3, 3
635 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 0, v0
636 ; GCN-NEXT: buffer_store_dword v3, v[1:2], s[0:3], 0 addr64 offset:12
637 ; GCN-NEXT: s_and_saveexec_b64 s[0:1], vcc
638 ; GCN-NEXT: s_cbranch_execz .LBB3_3
639 ; GCN-NEXT: ; %bb.2: ; %bb.inner.then2
640 ; GCN-NEXT: s_mov_b32 s10, 0
641 ; GCN-NEXT: s_mov_b32 s11, 0xf000
642 ; GCN-NEXT: s_mov_b32 s8, s10
643 ; GCN-NEXT: s_mov_b32 s9, s10
644 ; GCN-NEXT: v_mov_b32_e32 v0, 4
645 ; GCN-NEXT: buffer_store_dword v0, v[1:2], s[8:11], 0 addr64 offset:16
646 ; GCN-NEXT: .LBB3_3: ; %Flow
647 ; GCN-NEXT: s_or_b64 exec, exec, s[0:1]
648 ; GCN-NEXT: ; implicit-def: $vgpr1_vgpr2
649 ; GCN-NEXT: ; implicit-def: $vgpr0
650 ; GCN-NEXT: .LBB3_4: ; %Flow2
651 ; GCN-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
652 ; GCN-NEXT: s_cbranch_execz .LBB3_8
653 ; GCN-NEXT: ; %bb.5: ; %bb.outer.then
654 ; GCN-NEXT: s_mov_b32 s0, s2
655 ; GCN-NEXT: s_mov_b32 s1, s2
656 ; GCN-NEXT: s_waitcnt expcnt(0)
657 ; GCN-NEXT: v_mov_b32_e32 v3, 1
658 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 2, v0
659 ; GCN-NEXT: buffer_store_dword v3, v[1:2], s[0:3], 0 addr64 offset:4
660 ; GCN-NEXT: s_and_saveexec_b64 s[6:7], vcc
661 ; GCN-NEXT: s_cbranch_execz .LBB3_7
662 ; GCN-NEXT: ; %bb.6: ; %bb.inner.then
663 ; GCN-NEXT: v_mov_b32_e32 v0, 2
664 ; GCN-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64 offset:8
665 ; GCN-NEXT: .LBB3_7: ; %Flow1
666 ; GCN-NEXT: s_or_b64 exec, exec, s[6:7]
667 ; GCN-NEXT: .LBB3_8: ; %bb.outer.end
668 ; GCN-NEXT: s_or_b64 exec, exec, s[4:5]
669 ; GCN-NEXT: s_waitcnt expcnt(0)
670 ; GCN-NEXT: v_mov_b32_e32 v0, 3
671 ; GCN-NEXT: v_mov_b32_e32 v1, 0
672 ; GCN-NEXT: s_mov_b32 m0, -1
673 ; GCN-NEXT: ds_write_b32 v1, v0
676 ; GCN-O0-LABEL: nested_if_else_if:
677 ; GCN-O0: ; %bb.0: ; %bb
678 ; GCN-O0-NEXT: s_mov_b32 s12, SCRATCH_RSRC_DWORD0
679 ; GCN-O0-NEXT: s_mov_b32 s13, SCRATCH_RSRC_DWORD1
680 ; GCN-O0-NEXT: s_mov_b32 s14, -1
681 ; GCN-O0-NEXT: s_mov_b32 s15, 0xe8f000
682 ; GCN-O0-NEXT: s_add_u32 s12, s12, s11
683 ; GCN-O0-NEXT: s_addc_u32 s13, s13, 0
684 ; GCN-O0-NEXT: ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
685 ; GCN-O0-NEXT: v_mov_b32_e32 v1, v0
686 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
687 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
688 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
689 ; GCN-O0-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x9
690 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v1
691 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[12:15], 0 offset:16 ; 4-byte Folded Spill
692 ; GCN-O0-NEXT: s_mov_b32 s0, 2
693 ; GCN-O0-NEXT: v_lshlrev_b32_e64 v3, s0, v1
694 ; GCN-O0-NEXT: s_mov_b32 s1, 0
695 ; GCN-O0-NEXT: ; implicit-def: $sgpr1
696 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
697 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 0
698 ; GCN-O0-NEXT: ; kill: def $vgpr3 killed $vgpr3 def $vgpr3_vgpr4 killed $exec
699 ; GCN-O0-NEXT: v_mov_b32_e32 v4, v2
700 ; GCN-O0-NEXT: s_waitcnt lgkmcnt(0)
701 ; GCN-O0-NEXT: s_mov_b32 s2, s4
702 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v3
703 ; GCN-O0-NEXT: s_mov_b32 s1, s5
704 ; GCN-O0-NEXT: v_mov_b32_e32 v6, v4
705 ; GCN-O0-NEXT: v_add_i32_e64 v5, s[2:3], s2, v2
706 ; GCN-O0-NEXT: v_mov_b32_e32 v2, s1
707 ; GCN-O0-NEXT: v_addc_u32_e64 v2, s[2:3], v2, v6, s[2:3]
708 ; GCN-O0-NEXT: ; kill: def $vgpr5 killed $vgpr5 def $vgpr5_vgpr6 killed $exec
709 ; GCN-O0-NEXT: v_mov_b32_e32 v6, v2
710 ; GCN-O0-NEXT: buffer_store_dword v5, off, s[12:15], 0 offset:8 ; 4-byte Folded Spill
711 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
712 ; GCN-O0-NEXT: buffer_store_dword v6, off, s[12:15], 0 offset:12 ; 4-byte Folded Spill
713 ; GCN-O0-NEXT: s_mov_b32 s1, 0xf000
714 ; GCN-O0-NEXT: s_mov_b32 s2, 0
715 ; GCN-O0-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
716 ; GCN-O0-NEXT: s_mov_b32 s3, s1
717 ; GCN-O0-NEXT: ; kill: def $sgpr4_sgpr5 killed $sgpr4_sgpr5 def $sgpr4_sgpr5_sgpr6_sgpr7
718 ; GCN-O0-NEXT: s_mov_b64 s[6:7], s[2:3]
719 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 0
720 ; GCN-O0-NEXT: buffer_store_dword v2, v[3:4], s[4:7], 0 addr64
721 ; GCN-O0-NEXT: v_cmp_lt_u32_e64 s[0:1], v1, s0
722 ; GCN-O0-NEXT: s_mov_b64 s[2:3], exec
723 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[2:3], s[0:1]
724 ; GCN-O0-NEXT: s_xor_b64 s[2:3], s[0:1], s[2:3]
725 ; GCN-O0-NEXT: v_writelane_b32 v0, s2, 0
726 ; GCN-O0-NEXT: v_writelane_b32 v0, s3, 1
727 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
728 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
729 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
730 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
731 ; GCN-O0-NEXT: s_cbranch_execz .LBB3_1
732 ; GCN-O0-NEXT: s_branch .LBB3_4
733 ; GCN-O0-NEXT: .LBB3_1: ; %Flow2
734 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
735 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
736 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
737 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
738 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
739 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 0
740 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 1
741 ; GCN-O0-NEXT: s_or_saveexec_b64 s[0:1], s[0:1]
742 ; GCN-O0-NEXT: s_and_b64 s[0:1], exec, s[0:1]
743 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 2
744 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 3
745 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
746 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
747 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
748 ; GCN-O0-NEXT: s_xor_b64 exec, exec, s[0:1]
749 ; GCN-O0-NEXT: s_cbranch_execz .LBB3_8
750 ; GCN-O0-NEXT: ; %bb.2: ; %bb.outer.then
751 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
752 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
753 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
754 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
755 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:16 ; 4-byte Folded Reload
756 ; GCN-O0-NEXT: buffer_load_dword v3, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
757 ; GCN-O0-NEXT: buffer_load_dword v4, off, s[12:15], 0 offset:12 ; 4-byte Folded Reload
758 ; GCN-O0-NEXT: s_mov_b32 s0, 0xf000
759 ; GCN-O0-NEXT: s_mov_b32 s2, 0
760 ; GCN-O0-NEXT: s_mov_b32 s4, s2
761 ; GCN-O0-NEXT: s_mov_b32 s5, s0
762 ; GCN-O0-NEXT: s_mov_b32 s0, s2
763 ; GCN-O0-NEXT: s_mov_b32 s1, s2
764 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
765 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
766 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 1
767 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
768 ; GCN-O0-NEXT: buffer_store_dword v2, v[3:4], s[0:3], 0 addr64 offset:4
769 ; GCN-O0-NEXT: s_mov_b32 s0, 2
770 ; GCN-O0-NEXT: v_cmp_eq_u32_e64 s[2:3], v1, s0
771 ; GCN-O0-NEXT: s_mov_b64 s[0:1], exec
772 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 4
773 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 5
774 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
775 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
776 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
777 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[0:1], s[2:3]
778 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
779 ; GCN-O0-NEXT: s_cbranch_execz .LBB3_7
780 ; GCN-O0-NEXT: ; %bb.3: ; %bb.inner.then
781 ; GCN-O0-NEXT: s_waitcnt expcnt(1)
782 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
783 ; GCN-O0-NEXT: buffer_load_dword v2, off, s[12:15], 0 offset:12 ; 4-byte Folded Reload
784 ; GCN-O0-NEXT: s_mov_b32 s0, 0xf000
785 ; GCN-O0-NEXT: s_mov_b32 s2, 0
786 ; GCN-O0-NEXT: s_mov_b32 s4, s2
787 ; GCN-O0-NEXT: s_mov_b32 s5, s0
788 ; GCN-O0-NEXT: s_mov_b32 s0, s2
789 ; GCN-O0-NEXT: s_mov_b32 s1, s2
790 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
791 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
792 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
793 ; GCN-O0-NEXT: v_mov_b32_e32 v0, 2
794 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
795 ; GCN-O0-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64 offset:8
796 ; GCN-O0-NEXT: s_branch .LBB3_7
797 ; GCN-O0-NEXT: .LBB3_4: ; %bb.outer.else
798 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
799 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
800 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
801 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
802 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:16 ; 4-byte Folded Reload
803 ; GCN-O0-NEXT: buffer_load_dword v3, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
804 ; GCN-O0-NEXT: buffer_load_dword v4, off, s[12:15], 0 offset:12 ; 4-byte Folded Reload
805 ; GCN-O0-NEXT: s_mov_b32 s1, 0xf000
806 ; GCN-O0-NEXT: s_mov_b32 s0, 0
807 ; GCN-O0-NEXT: s_mov_b32 s2, s0
808 ; GCN-O0-NEXT: s_mov_b32 s3, s1
809 ; GCN-O0-NEXT: s_mov_b32 s4, s0
810 ; GCN-O0-NEXT: s_mov_b32 s5, s0
811 ; GCN-O0-NEXT: ; kill: def $sgpr4_sgpr5 killed $sgpr4_sgpr5 def $sgpr4_sgpr5_sgpr6_sgpr7
812 ; GCN-O0-NEXT: s_mov_b64 s[6:7], s[2:3]
813 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 3
814 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
815 ; GCN-O0-NEXT: buffer_store_dword v2, v[3:4], s[4:7], 0 addr64 offset:12
816 ; GCN-O0-NEXT: v_cmp_eq_u32_e64 s[2:3], v1, s0
817 ; GCN-O0-NEXT: s_mov_b64 s[0:1], exec
818 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 6
819 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 7
820 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
821 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
822 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
823 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[0:1], s[2:3]
824 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
825 ; GCN-O0-NEXT: s_cbranch_execz .LBB3_6
826 ; GCN-O0-NEXT: ; %bb.5: ; %bb.inner.then2
827 ; GCN-O0-NEXT: s_waitcnt expcnt(1)
828 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
829 ; GCN-O0-NEXT: buffer_load_dword v2, off, s[12:15], 0 offset:12 ; 4-byte Folded Reload
830 ; GCN-O0-NEXT: s_mov_b32 s0, 0xf000
831 ; GCN-O0-NEXT: s_mov_b32 s2, 0
832 ; GCN-O0-NEXT: s_mov_b32 s4, s2
833 ; GCN-O0-NEXT: s_mov_b32 s5, s0
834 ; GCN-O0-NEXT: s_mov_b32 s0, s2
835 ; GCN-O0-NEXT: s_mov_b32 s1, s2
836 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
837 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
838 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
839 ; GCN-O0-NEXT: v_mov_b32_e32 v0, 4
840 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
841 ; GCN-O0-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64 offset:16
842 ; GCN-O0-NEXT: .LBB3_6: ; %Flow
843 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
844 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
845 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
846 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
847 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
848 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 6
849 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 7
850 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[0:1]
851 ; GCN-O0-NEXT: s_branch .LBB3_1
852 ; GCN-O0-NEXT: .LBB3_7: ; %Flow1
853 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
854 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
855 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
856 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
857 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
858 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 4
859 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 5
860 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[0:1]
861 ; GCN-O0-NEXT: .LBB3_8: ; %bb.outer.end
862 ; GCN-O0-NEXT: s_or_saveexec_b64 s[8:9], -1
863 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
864 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
865 ; GCN-O0-NEXT: s_mov_b64 exec, s[8:9]
866 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
867 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 2
868 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 3
869 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[0:1]
870 ; GCN-O0-NEXT: v_mov_b32_e32 v2, 3
871 ; GCN-O0-NEXT: v_mov_b32_e32 v1, 0
872 ; GCN-O0-NEXT: s_mov_b32 m0, -1
873 ; GCN-O0-NEXT: ds_write_b32 v1, v2
874 ; GCN-O0-NEXT: ; kill: killed $vgpr0
875 ; GCN-O0-NEXT: s_endpgm
877 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x()
878 %tmp1 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp
879 store i32 0, ptr addrspace(1) %tmp1, align 4
880 %cc1 = icmp ugt i32 %tmp, 1
881 br i1 %cc1, label %bb.outer.then, label %bb.outer.else
884 %tmp2 = getelementptr inbounds i32, ptr addrspace(1) %tmp1, i32 1
885 store i32 1, ptr addrspace(1) %tmp2, align 4
886 %cc2 = icmp eq i32 %tmp, 2
887 br i1 %cc2, label %bb.inner.then, label %bb.outer.end
890 %tmp3 = getelementptr inbounds i32, ptr addrspace(1) %tmp1, i32 2
891 store i32 2, ptr addrspace(1) %tmp3, align 4
892 br label %bb.outer.end
895 %tmp4 = getelementptr inbounds i32, ptr addrspace(1) %tmp1, i32 3
896 store i32 3, ptr addrspace(1) %tmp4, align 4
897 %cc3 = icmp eq i32 %tmp, 0 ; avoid being optimized away through the domination
898 br i1 %cc3, label %bb.inner.then2, label %bb.outer.end
901 %tmp5 = getelementptr inbounds i32, ptr addrspace(1) %tmp1, i32 4
902 store i32 4, ptr addrspace(1) %tmp5, align 4
903 br label %bb.outer.end
906 store i32 3, ptr addrspace(3) null
910 define amdgpu_kernel void @s_endpgm_unsafe_barrier(ptr addrspace(1) nocapture %arg) {
911 ; GCN-LABEL: s_endpgm_unsafe_barrier:
912 ; GCN: ; %bb.0: ; %bb
913 ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, 1, v0
914 ; GCN-NEXT: s_and_saveexec_b64 s[2:3], vcc
915 ; GCN-NEXT: s_cbranch_execz .LBB4_2
916 ; GCN-NEXT: ; %bb.1: ; %bb.then
917 ; GCN-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
918 ; GCN-NEXT: s_mov_b32 s7, 0xf000
919 ; GCN-NEXT: s_mov_b32 s6, 0
920 ; GCN-NEXT: v_lshlrev_b32_e32 v0, 2, v0
921 ; GCN-NEXT: v_mov_b32_e32 v1, 0
922 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
923 ; GCN-NEXT: buffer_store_dword v1, v[0:1], s[4:7], 0 addr64
924 ; GCN-NEXT: .LBB4_2: ; %bb.end
925 ; GCN-NEXT: s_or_b64 exec, exec, s[2:3]
926 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0)
927 ; GCN-NEXT: s_barrier
930 ; GCN-O0-LABEL: s_endpgm_unsafe_barrier:
931 ; GCN-O0: ; %bb.0: ; %bb
932 ; GCN-O0-NEXT: s_mov_b32 s12, SCRATCH_RSRC_DWORD0
933 ; GCN-O0-NEXT: s_mov_b32 s13, SCRATCH_RSRC_DWORD1
934 ; GCN-O0-NEXT: s_mov_b32 s14, -1
935 ; GCN-O0-NEXT: s_mov_b32 s15, 0xe8f000
936 ; GCN-O0-NEXT: s_add_u32 s12, s12, s11
937 ; GCN-O0-NEXT: s_addc_u32 s13, s13, 0
938 ; GCN-O0-NEXT: ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
939 ; GCN-O0-NEXT: v_mov_b32_e32 v1, v0
940 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
941 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
942 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
943 ; GCN-O0-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x9
944 ; GCN-O0-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
945 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 0
946 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 1
947 ; GCN-O0-NEXT: v_mov_b32_e32 v2, v1
948 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[12:15], 0 offset:8 ; 4-byte Folded Spill
949 ; GCN-O0-NEXT: s_mov_b32 s0, 1
950 ; GCN-O0-NEXT: v_cmp_gt_u32_e64 s[2:3], v1, s0
951 ; GCN-O0-NEXT: s_mov_b64 s[0:1], exec
952 ; GCN-O0-NEXT: v_writelane_b32 v0, s0, 2
953 ; GCN-O0-NEXT: v_writelane_b32 v0, s1, 3
954 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
955 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Spill
956 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
957 ; GCN-O0-NEXT: s_and_b64 s[0:1], s[0:1], s[2:3]
958 ; GCN-O0-NEXT: s_mov_b64 exec, s[0:1]
959 ; GCN-O0-NEXT: s_cbranch_execz .LBB4_2
960 ; GCN-O0-NEXT: ; %bb.1: ; %bb.then
961 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
962 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
963 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
964 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
965 ; GCN-O0-NEXT: v_readlane_b32 s0, v1, 0
966 ; GCN-O0-NEXT: v_readlane_b32 s1, v1, 1
967 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
968 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:8 ; 4-byte Folded Reload
969 ; GCN-O0-NEXT: s_mov_b32 s2, 0xf000
970 ; GCN-O0-NEXT: s_mov_b32 s4, 0
971 ; GCN-O0-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
972 ; GCN-O0-NEXT: s_mov_b32 s5, s2
973 ; GCN-O0-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr0_sgpr1 def $sgpr0_sgpr1_sgpr2_sgpr3
974 ; GCN-O0-NEXT: s_mov_b64 s[2:3], s[4:5]
975 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
976 ; GCN-O0-NEXT: v_ashrrev_i32_e64 v2, 31, v0
977 ; GCN-O0-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
978 ; GCN-O0-NEXT: v_mov_b32_e32 v1, v2
979 ; GCN-O0-NEXT: s_mov_b32 s4, 2
980 ; GCN-O0-NEXT: v_lshl_b64 v[1:2], v[0:1], s4
981 ; GCN-O0-NEXT: v_mov_b32_e32 v0, 0
982 ; GCN-O0-NEXT: buffer_store_dword v0, v[1:2], s[0:3], 0 addr64
983 ; GCN-O0-NEXT: .LBB4_2: ; %bb.end
984 ; GCN-O0-NEXT: s_or_saveexec_b64 s[6:7], -1
985 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
986 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[12:15], 0 offset:4 ; 4-byte Folded Reload
987 ; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]
988 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
989 ; GCN-O0-NEXT: v_readlane_b32 s0, v0, 2
990 ; GCN-O0-NEXT: v_readlane_b32 s1, v0, 3
991 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[0:1]
992 ; GCN-O0-NEXT: s_barrier
993 ; GCN-O0-NEXT: ; kill: killed $vgpr0
994 ; GCN-O0-NEXT: s_endpgm
996 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x()
997 %tmp1 = icmp ugt i32 %tmp, 1
998 br i1 %tmp1, label %bb.then, label %bb.end
1000 bb.then: ; preds = %bb
1001 %tmp4 = getelementptr inbounds i32, ptr addrspace(1) %arg, i32 %tmp
1002 store i32 0, ptr addrspace(1) %tmp4, align 4
1005 bb.end: ; preds = %bb.then, %bb
1006 call void @llvm.amdgcn.s.barrier()
1010 define void @scc_liveness(i32 %arg) local_unnamed_addr #0 {
1011 ; GCN-LABEL: scc_liveness:
1012 ; GCN: ; %bb.0: ; %bb
1013 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1014 ; GCN-NEXT: s_movk_i32 s4, 0x207
1015 ; GCN-NEXT: v_cmp_gt_i32_e32 vcc, s4, v0
1016 ; GCN-NEXT: s_mov_b32 s8, 0
1017 ; GCN-NEXT: v_cmp_eq_u32_e64 s[4:5], 0, v0
1018 ; GCN-NEXT: s_mov_b64 s[12:13], 0
1019 ; GCN-NEXT: s_mov_b64 s[6:7], 0
1020 ; GCN-NEXT: s_branch .LBB5_3
1021 ; GCN-NEXT: .LBB5_1: ; %Flow
1022 ; GCN-NEXT: ; in Loop: Header=BB5_3 Depth=1
1023 ; GCN-NEXT: s_or_b64 exec, exec, s[10:11]
1024 ; GCN-NEXT: .LBB5_2: ; %bb10
1025 ; GCN-NEXT: ; in Loop: Header=BB5_3 Depth=1
1026 ; GCN-NEXT: s_or_b64 exec, exec, s[14:15]
1027 ; GCN-NEXT: s_and_b64 s[6:7], exec, s[4:5]
1028 ; GCN-NEXT: s_or_b64 s[12:13], s[6:7], s[12:13]
1029 ; GCN-NEXT: s_mov_b64 s[6:7], 0
1030 ; GCN-NEXT: s_andn2_b64 exec, exec, s[12:13]
1031 ; GCN-NEXT: s_cbranch_execz .LBB5_7
1032 ; GCN-NEXT: .LBB5_3: ; %bb1
1033 ; GCN-NEXT: ; =>This Inner Loop Header: Depth=1
1034 ; GCN-NEXT: s_and_b64 s[10:11], exec, vcc
1035 ; GCN-NEXT: s_or_b64 s[6:7], s[10:11], s[6:7]
1036 ; GCN-NEXT: s_andn2_b64 exec, exec, s[6:7]
1037 ; GCN-NEXT: s_cbranch_execnz .LBB5_3
1038 ; GCN-NEXT: ; %bb.4: ; %bb2
1039 ; GCN-NEXT: ; in Loop: Header=BB5_3 Depth=1
1040 ; GCN-NEXT: s_or_b64 exec, exec, s[6:7]
1041 ; GCN-NEXT: s_mov_b32 s9, s8
1042 ; GCN-NEXT: s_mov_b32 s10, s8
1043 ; GCN-NEXT: s_mov_b32 s11, s8
1044 ; GCN-NEXT: v_mov_b32_e32 v0, s8
1045 ; GCN-NEXT: v_mov_b32_e32 v1, s9
1046 ; GCN-NEXT: v_mov_b32_e32 v2, s10
1047 ; GCN-NEXT: v_mov_b32_e32 v3, s11
1048 ; GCN-NEXT: s_and_saveexec_b64 s[14:15], s[4:5]
1049 ; GCN-NEXT: s_cbranch_execz .LBB5_2
1050 ; GCN-NEXT: ; %bb.5: ; %bb4
1051 ; GCN-NEXT: ; in Loop: Header=BB5_3 Depth=1
1052 ; GCN-NEXT: buffer_load_dword v0, v0, s[0:3], 0 offen
1053 ; GCN-NEXT: s_waitcnt vmcnt(0)
1054 ; GCN-NEXT: v_cmp_gt_f32_e64 s[6:7], 0, v0
1055 ; GCN-NEXT: v_mov_b32_e32 v0, s8
1056 ; GCN-NEXT: v_mov_b32_e32 v1, s9
1057 ; GCN-NEXT: v_mov_b32_e32 v2, s10
1058 ; GCN-NEXT: v_mov_b32_e32 v3, s11
1059 ; GCN-NEXT: s_and_saveexec_b64 s[10:11], s[6:7]
1060 ; GCN-NEXT: s_cbranch_execz .LBB5_1
1061 ; GCN-NEXT: ; %bb.6: ; %bb8
1062 ; GCN-NEXT: ; in Loop: Header=BB5_3 Depth=1
1063 ; GCN-NEXT: s_mov_b32 s9, s8
1064 ; GCN-NEXT: v_mov_b32_e32 v0, s8
1065 ; GCN-NEXT: v_mov_b32_e32 v1, s9
1066 ; GCN-NEXT: v_mov_b32_e32 v2, s10
1067 ; GCN-NEXT: v_mov_b32_e32 v3, s11
1068 ; GCN-NEXT: s_branch .LBB5_1
1069 ; GCN-NEXT: .LBB5_7: ; %bb12
1070 ; GCN-NEXT: s_or_b64 exec, exec, s[12:13]
1071 ; GCN-NEXT: buffer_store_dword v3, v0, s[0:3], 0 offen
1072 ; GCN-NEXT: s_waitcnt vmcnt(0)
1073 ; GCN-NEXT: buffer_store_dword v2, v0, s[0:3], 0 offen
1074 ; GCN-NEXT: s_waitcnt vmcnt(0)
1075 ; GCN-NEXT: buffer_store_dword v1, v0, s[0:3], 0 offen
1076 ; GCN-NEXT: s_waitcnt vmcnt(0)
1077 ; GCN-NEXT: buffer_store_dword v0, v0, s[0:3], 0 offen
1078 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0)
1079 ; GCN-NEXT: s_setpc_b64 s[30:31]
1081 ; GCN-O0-LABEL: scc_liveness:
1082 ; GCN-O0: ; %bb.0: ; %bb
1083 ; GCN-O0-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1084 ; GCN-O0-NEXT: s_xor_saveexec_b64 s[4:5], -1
1085 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 offset:72 ; 4-byte Folded Spill
1086 ; GCN-O0-NEXT: buffer_store_dword v4, off, s[0:3], s32 offset:76 ; 4-byte Folded Spill
1087 ; GCN-O0-NEXT: s_mov_b64 exec, s[4:5]
1088 ; GCN-O0-NEXT: ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
1089 ; GCN-O0-NEXT: v_mov_b32_e32 v1, v0
1090 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1091 ; GCN-O0-NEXT: s_waitcnt expcnt(1)
1092 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 ; 4-byte Folded Reload
1093 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1094 ; GCN-O0-NEXT: buffer_store_dword v1, off, s[0:3], s32 offset:4 ; 4-byte Folded Spill
1095 ; GCN-O0-NEXT: s_mov_b64 s[4:5], 0
1096 ; GCN-O0-NEXT: s_mov_b64 s[6:7], s[4:5]
1097 ; GCN-O0-NEXT: s_waitcnt vmcnt(1)
1098 ; GCN-O0-NEXT: v_writelane_b32 v0, s6, 0
1099 ; GCN-O0-NEXT: v_writelane_b32 v0, s7, 1
1100 ; GCN-O0-NEXT: v_writelane_b32 v0, s4, 2
1101 ; GCN-O0-NEXT: v_writelane_b32 v0, s5, 3
1102 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1103 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 ; 4-byte Folded Spill
1104 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1105 ; GCN-O0-NEXT: .LBB5_1: ; %bb1
1106 ; GCN-O0-NEXT: ; =>This Inner Loop Header: Depth=1
1107 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1108 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
1109 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 ; 4-byte Folded Reload
1110 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1111 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1112 ; GCN-O0-NEXT: v_readlane_b32 s8, v0, 2
1113 ; GCN-O0-NEXT: v_readlane_b32 s9, v0, 3
1114 ; GCN-O0-NEXT: v_readlane_b32 s6, v0, 0
1115 ; GCN-O0-NEXT: v_readlane_b32 s7, v0, 1
1116 ; GCN-O0-NEXT: v_writelane_b32 v0, s6, 4
1117 ; GCN-O0-NEXT: v_writelane_b32 v0, s7, 5
1118 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[0:3], s32 offset:4 ; 4-byte Folded Reload
1119 ; GCN-O0-NEXT: s_mov_b32 s4, 0x207
1120 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1121 ; GCN-O0-NEXT: v_cmp_lt_i32_e64 s[4:5], v1, s4
1122 ; GCN-O0-NEXT: s_or_b64 s[4:5], s[4:5], s[8:9]
1123 ; GCN-O0-NEXT: v_writelane_b32 v0, s4, 6
1124 ; GCN-O0-NEXT: v_writelane_b32 v0, s5, 7
1125 ; GCN-O0-NEXT: v_writelane_b32 v0, s6, 0
1126 ; GCN-O0-NEXT: v_writelane_b32 v0, s7, 1
1127 ; GCN-O0-NEXT: s_mov_b64 s[6:7], s[4:5]
1128 ; GCN-O0-NEXT: v_writelane_b32 v0, s6, 2
1129 ; GCN-O0-NEXT: v_writelane_b32 v0, s7, 3
1130 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1131 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 ; 4-byte Folded Spill
1132 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1133 ; GCN-O0-NEXT: s_andn2_b64 exec, exec, s[4:5]
1134 ; GCN-O0-NEXT: s_cbranch_execnz .LBB5_1
1135 ; GCN-O0-NEXT: ; %bb.2: ; %bb2
1136 ; GCN-O0-NEXT: ; in Loop: Header=BB5_1 Depth=1
1137 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1138 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
1139 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 ; 4-byte Folded Reload
1140 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1141 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1142 ; GCN-O0-NEXT: v_readlane_b32 s4, v0, 6
1143 ; GCN-O0-NEXT: v_readlane_b32 s5, v0, 7
1144 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[4:5]
1145 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[0:3], s32 offset:4 ; 4-byte Folded Reload
1146 ; GCN-O0-NEXT: s_mov_b32 s6, 0
1147 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1148 ; GCN-O0-NEXT: v_cmp_ne_u32_e64 s[4:5], v1, s6
1149 ; GCN-O0-NEXT: v_cmp_eq_u32_e64 s[6:7], v1, s6
1150 ; GCN-O0-NEXT: v_writelane_b32 v0, s4, 8
1151 ; GCN-O0-NEXT: v_writelane_b32 v0, s5, 9
1152 ; GCN-O0-NEXT: s_mov_b32 s4, 0
1153 ; GCN-O0-NEXT: s_mov_b32 s8, s4
1154 ; GCN-O0-NEXT: s_mov_b32 s9, s4
1155 ; GCN-O0-NEXT: s_mov_b32 s10, s4
1156 ; GCN-O0-NEXT: s_mov_b32 s11, s4
1157 ; GCN-O0-NEXT: v_mov_b32_e32 v1, s8
1158 ; GCN-O0-NEXT: v_mov_b32_e32 v2, s9
1159 ; GCN-O0-NEXT: v_mov_b32_e32 v3, s10
1160 ; GCN-O0-NEXT: v_mov_b32_e32 v4, s11
1161 ; GCN-O0-NEXT: buffer_store_dword v1, off, s[0:3], s32 offset:8 ; 4-byte Folded Spill
1162 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1163 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[0:3], s32 offset:12 ; 4-byte Folded Spill
1164 ; GCN-O0-NEXT: buffer_store_dword v3, off, s[0:3], s32 offset:16 ; 4-byte Folded Spill
1165 ; GCN-O0-NEXT: buffer_store_dword v4, off, s[0:3], s32 offset:20 ; 4-byte Folded Spill
1166 ; GCN-O0-NEXT: s_mov_b64 s[4:5], exec
1167 ; GCN-O0-NEXT: v_writelane_b32 v0, s4, 10
1168 ; GCN-O0-NEXT: v_writelane_b32 v0, s5, 11
1169 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1170 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 ; 4-byte Folded Spill
1171 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1172 ; GCN-O0-NEXT: s_and_b64 s[4:5], s[4:5], s[6:7]
1173 ; GCN-O0-NEXT: s_mov_b64 exec, s[4:5]
1174 ; GCN-O0-NEXT: s_cbranch_execz .LBB5_5
1175 ; GCN-O0-NEXT: ; %bb.3: ; %bb4
1176 ; GCN-O0-NEXT: ; in Loop: Header=BB5_1 Depth=1
1177 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1178 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
1179 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 ; 4-byte Folded Reload
1180 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1181 ; GCN-O0-NEXT: ; implicit-def: $sgpr4
1182 ; GCN-O0-NEXT: v_mov_b32_e32 v1, s4
1183 ; GCN-O0-NEXT: buffer_load_dword v1, v1, s[0:3], 0 offen
1184 ; GCN-O0-NEXT: s_mov_b32 s4, 0
1185 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1186 ; GCN-O0-NEXT: v_cmp_lt_f32_e64 s[6:7], v1, s4
1187 ; GCN-O0-NEXT: s_mov_b32 s8, s4
1188 ; GCN-O0-NEXT: s_mov_b32 s9, s4
1189 ; GCN-O0-NEXT: s_mov_b32 s10, s4
1190 ; GCN-O0-NEXT: s_mov_b32 s11, s4
1191 ; GCN-O0-NEXT: v_mov_b32_e32 v1, s8
1192 ; GCN-O0-NEXT: v_mov_b32_e32 v2, s9
1193 ; GCN-O0-NEXT: v_mov_b32_e32 v3, s10
1194 ; GCN-O0-NEXT: v_mov_b32_e32 v4, s11
1195 ; GCN-O0-NEXT: buffer_store_dword v1, off, s[0:3], s32 offset:24 ; 4-byte Folded Spill
1196 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1197 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[0:3], s32 offset:28 ; 4-byte Folded Spill
1198 ; GCN-O0-NEXT: buffer_store_dword v3, off, s[0:3], s32 offset:32 ; 4-byte Folded Spill
1199 ; GCN-O0-NEXT: buffer_store_dword v4, off, s[0:3], s32 offset:36 ; 4-byte Folded Spill
1200 ; GCN-O0-NEXT: s_mov_b64 s[4:5], exec
1201 ; GCN-O0-NEXT: v_writelane_b32 v0, s4, 12
1202 ; GCN-O0-NEXT: v_writelane_b32 v0, s5, 13
1203 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1204 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 ; 4-byte Folded Spill
1205 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1206 ; GCN-O0-NEXT: s_and_b64 s[4:5], s[4:5], s[6:7]
1207 ; GCN-O0-NEXT: s_mov_b64 exec, s[4:5]
1208 ; GCN-O0-NEXT: s_cbranch_execz .LBB5_6
1209 ; GCN-O0-NEXT: ; %bb.4: ; %bb8
1210 ; GCN-O0-NEXT: ; in Loop: Header=BB5_1 Depth=1
1211 ; GCN-O0-NEXT: s_mov_b32 s10, 0
1212 ; GCN-O0-NEXT: ; implicit-def: $sgpr4
1213 ; GCN-O0-NEXT: ; implicit-def: $sgpr5
1214 ; GCN-O0-NEXT: ; implicit-def: $sgpr9
1215 ; GCN-O0-NEXT: ; implicit-def: $sgpr5
1216 ; GCN-O0-NEXT: ; implicit-def: $sgpr8
1217 ; GCN-O0-NEXT: ; implicit-def: $sgpr5
1218 ; GCN-O0-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
1219 ; GCN-O0-NEXT: s_mov_b32 s5, s10
1220 ; GCN-O0-NEXT: s_mov_b32 s6, s9
1221 ; GCN-O0-NEXT: s_mov_b32 s7, s8
1222 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
1223 ; GCN-O0-NEXT: v_mov_b32_e32 v0, s4
1224 ; GCN-O0-NEXT: v_mov_b32_e32 v1, s5
1225 ; GCN-O0-NEXT: v_mov_b32_e32 v2, s6
1226 ; GCN-O0-NEXT: v_mov_b32_e32 v3, s7
1227 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 offset:24 ; 4-byte Folded Spill
1228 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1229 ; GCN-O0-NEXT: buffer_store_dword v1, off, s[0:3], s32 offset:28 ; 4-byte Folded Spill
1230 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[0:3], s32 offset:32 ; 4-byte Folded Spill
1231 ; GCN-O0-NEXT: buffer_store_dword v3, off, s[0:3], s32 offset:36 ; 4-byte Folded Spill
1232 ; GCN-O0-NEXT: s_branch .LBB5_6
1233 ; GCN-O0-NEXT: .LBB5_5: ; %Flow2
1234 ; GCN-O0-NEXT: ; in Loop: Header=BB5_1 Depth=1
1235 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1236 ; GCN-O0-NEXT: s_waitcnt expcnt(1)
1237 ; GCN-O0-NEXT: buffer_load_dword v4, off, s[0:3], s32 ; 4-byte Folded Reload
1238 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1239 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1240 ; GCN-O0-NEXT: v_readlane_b32 s4, v4, 10
1241 ; GCN-O0-NEXT: v_readlane_b32 s5, v4, 11
1242 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[4:5]
1243 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
1244 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 offset:8 ; 4-byte Folded Reload
1245 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[0:3], s32 offset:12 ; 4-byte Folded Reload
1246 ; GCN-O0-NEXT: buffer_load_dword v2, off, s[0:3], s32 offset:16 ; 4-byte Folded Reload
1247 ; GCN-O0-NEXT: buffer_load_dword v3, off, s[0:3], s32 offset:20 ; 4-byte Folded Reload
1248 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1249 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 offset:40 ; 4-byte Folded Spill
1250 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1251 ; GCN-O0-NEXT: buffer_store_dword v1, off, s[0:3], s32 offset:44 ; 4-byte Folded Spill
1252 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[0:3], s32 offset:48 ; 4-byte Folded Spill
1253 ; GCN-O0-NEXT: buffer_store_dword v3, off, s[0:3], s32 offset:52 ; 4-byte Folded Spill
1254 ; GCN-O0-NEXT: s_branch .LBB5_7
1255 ; GCN-O0-NEXT: .LBB5_6: ; %Flow
1256 ; GCN-O0-NEXT: ; in Loop: Header=BB5_1 Depth=1
1257 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1258 ; GCN-O0-NEXT: s_waitcnt expcnt(1)
1259 ; GCN-O0-NEXT: buffer_load_dword v4, off, s[0:3], s32 ; 4-byte Folded Reload
1260 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1261 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1262 ; GCN-O0-NEXT: v_readlane_b32 s4, v4, 12
1263 ; GCN-O0-NEXT: v_readlane_b32 s5, v4, 13
1264 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[4:5]
1265 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
1266 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 offset:24 ; 4-byte Folded Reload
1267 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[0:3], s32 offset:28 ; 4-byte Folded Reload
1268 ; GCN-O0-NEXT: buffer_load_dword v2, off, s[0:3], s32 offset:32 ; 4-byte Folded Reload
1269 ; GCN-O0-NEXT: buffer_load_dword v3, off, s[0:3], s32 offset:36 ; 4-byte Folded Reload
1270 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1271 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 offset:8 ; 4-byte Folded Spill
1272 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1273 ; GCN-O0-NEXT: buffer_store_dword v1, off, s[0:3], s32 offset:12 ; 4-byte Folded Spill
1274 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[0:3], s32 offset:16 ; 4-byte Folded Spill
1275 ; GCN-O0-NEXT: buffer_store_dword v3, off, s[0:3], s32 offset:20 ; 4-byte Folded Spill
1276 ; GCN-O0-NEXT: s_branch .LBB5_5
1277 ; GCN-O0-NEXT: .LBB5_7: ; %bb10
1278 ; GCN-O0-NEXT: ; in Loop: Header=BB5_1 Depth=1
1279 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1280 ; GCN-O0-NEXT: s_waitcnt expcnt(3)
1281 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 ; 4-byte Folded Reload
1282 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1283 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1284 ; GCN-O0-NEXT: v_readlane_b32 s6, v0, 8
1285 ; GCN-O0-NEXT: v_readlane_b32 s7, v0, 9
1286 ; GCN-O0-NEXT: s_mov_b64 s[4:5], -1
1287 ; GCN-O0-NEXT: v_writelane_b32 v0, s4, 14
1288 ; GCN-O0-NEXT: v_writelane_b32 v0, s5, 15
1289 ; GCN-O0-NEXT: s_mov_b64 s[4:5], exec
1290 ; GCN-O0-NEXT: v_writelane_b32 v0, s4, 16
1291 ; GCN-O0-NEXT: v_writelane_b32 v0, s5, 17
1292 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1293 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 ; 4-byte Folded Spill
1294 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1295 ; GCN-O0-NEXT: s_and_b64 s[4:5], s[4:5], s[6:7]
1296 ; GCN-O0-NEXT: s_mov_b64 exec, s[4:5]
1297 ; GCN-O0-NEXT: s_cbranch_execz .LBB5_9
1298 ; GCN-O0-NEXT: ; %bb.8: ; %Flow1
1299 ; GCN-O0-NEXT: ; in Loop: Header=BB5_1 Depth=1
1300 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1301 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
1302 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 ; 4-byte Folded Reload
1303 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1304 ; GCN-O0-NEXT: s_mov_b64 s[4:5], 0
1305 ; GCN-O0-NEXT: s_xor_b64 s[4:5], exec, -1
1306 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1307 ; GCN-O0-NEXT: v_writelane_b32 v0, s4, 14
1308 ; GCN-O0-NEXT: v_writelane_b32 v0, s5, 15
1309 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1310 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 ; 4-byte Folded Spill
1311 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1312 ; GCN-O0-NEXT: .LBB5_9: ; %Flow3
1313 ; GCN-O0-NEXT: ; in Loop: Header=BB5_1 Depth=1
1314 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1315 ; GCN-O0-NEXT: buffer_load_dword v4, off, s[0:3], s32 ; 4-byte Folded Reload
1316 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1317 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1318 ; GCN-O0-NEXT: v_readlane_b32 s8, v4, 16
1319 ; GCN-O0-NEXT: v_readlane_b32 s9, v4, 17
1320 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[8:9]
1321 ; GCN-O0-NEXT: v_readlane_b32 s6, v4, 4
1322 ; GCN-O0-NEXT: v_readlane_b32 s7, v4, 5
1323 ; GCN-O0-NEXT: v_readlane_b32 s4, v4, 14
1324 ; GCN-O0-NEXT: v_readlane_b32 s5, v4, 15
1325 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
1326 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 offset:40 ; 4-byte Folded Reload
1327 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[0:3], s32 offset:44 ; 4-byte Folded Reload
1328 ; GCN-O0-NEXT: buffer_load_dword v2, off, s[0:3], s32 offset:48 ; 4-byte Folded Reload
1329 ; GCN-O0-NEXT: buffer_load_dword v3, off, s[0:3], s32 offset:52 ; 4-byte Folded Reload
1330 ; GCN-O0-NEXT: s_and_b64 s[4:5], exec, s[4:5]
1331 ; GCN-O0-NEXT: s_or_b64 s[4:5], s[4:5], s[6:7]
1332 ; GCN-O0-NEXT: s_mov_b64 s[6:7], 0
1333 ; GCN-O0-NEXT: s_mov_b64 s[8:9], s[4:5]
1334 ; GCN-O0-NEXT: v_writelane_b32 v4, s8, 0
1335 ; GCN-O0-NEXT: v_writelane_b32 v4, s9, 1
1336 ; GCN-O0-NEXT: v_writelane_b32 v4, s6, 2
1337 ; GCN-O0-NEXT: v_writelane_b32 v4, s7, 3
1338 ; GCN-O0-NEXT: s_mov_b64 s[6:7], s[4:5]
1339 ; GCN-O0-NEXT: v_writelane_b32 v4, s6, 18
1340 ; GCN-O0-NEXT: v_writelane_b32 v4, s7, 19
1341 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1342 ; GCN-O0-NEXT: buffer_store_dword v4, off, s[0:3], s32 ; 4-byte Folded Spill
1343 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1344 ; GCN-O0-NEXT: s_waitcnt vmcnt(1)
1345 ; GCN-O0-NEXT: buffer_store_dword v0, off, s[0:3], s32 offset:56 ; 4-byte Folded Spill
1346 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1347 ; GCN-O0-NEXT: buffer_store_dword v1, off, s[0:3], s32 offset:60 ; 4-byte Folded Spill
1348 ; GCN-O0-NEXT: buffer_store_dword v2, off, s[0:3], s32 offset:64 ; 4-byte Folded Spill
1349 ; GCN-O0-NEXT: buffer_store_dword v3, off, s[0:3], s32 offset:68 ; 4-byte Folded Spill
1350 ; GCN-O0-NEXT: s_andn2_b64 exec, exec, s[4:5]
1351 ; GCN-O0-NEXT: s_cbranch_execnz .LBB5_1
1352 ; GCN-O0-NEXT: ; %bb.10: ; %bb12
1353 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1354 ; GCN-O0-NEXT: s_waitcnt expcnt(3)
1355 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 ; 4-byte Folded Reload
1356 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1357 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1358 ; GCN-O0-NEXT: v_readlane_b32 s4, v0, 18
1359 ; GCN-O0-NEXT: v_readlane_b32 s5, v0, 19
1360 ; GCN-O0-NEXT: s_or_b64 exec, exec, s[4:5]
1361 ; GCN-O0-NEXT: ; %bb.11: ; %bb12
1362 ; GCN-O0-NEXT: s_or_saveexec_b64 s[14:15], -1
1363 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 ; 4-byte Folded Reload
1364 ; GCN-O0-NEXT: s_mov_b64 exec, s[14:15]
1365 ; GCN-O0-NEXT: s_waitcnt expcnt(0)
1366 ; GCN-O0-NEXT: buffer_load_dword v1, off, s[0:3], s32 offset:56 ; 4-byte Folded Reload
1367 ; GCN-O0-NEXT: buffer_load_dword v2, off, s[0:3], s32 offset:60 ; 4-byte Folded Reload
1368 ; GCN-O0-NEXT: buffer_load_dword v3, off, s[0:3], s32 offset:64 ; 4-byte Folded Reload
1369 ; GCN-O0-NEXT: buffer_load_dword v4, off, s[0:3], s32 offset:68 ; 4-byte Folded Reload
1370 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1371 ; GCN-O0-NEXT: v_mov_b32_e32 v5, v4
1372 ; GCN-O0-NEXT: ; implicit-def: $sgpr4
1373 ; GCN-O0-NEXT: v_mov_b32_e32 v6, s4
1374 ; GCN-O0-NEXT: buffer_store_dword v5, v6, s[0:3], 0 offen
1375 ; GCN-O0-NEXT: s_waitcnt vmcnt(0) expcnt(0)
1376 ; GCN-O0-NEXT: v_mov_b32_e32 v5, v3
1377 ; GCN-O0-NEXT: ; implicit-def: $sgpr4
1378 ; GCN-O0-NEXT: v_mov_b32_e32 v6, s4
1379 ; GCN-O0-NEXT: buffer_store_dword v5, v6, s[0:3], 0 offen
1380 ; GCN-O0-NEXT: s_waitcnt vmcnt(0) expcnt(0)
1381 ; GCN-O0-NEXT: v_mov_b32_e32 v5, v2
1382 ; GCN-O0-NEXT: ; implicit-def: $sgpr4
1383 ; GCN-O0-NEXT: v_mov_b32_e32 v6, s4
1384 ; GCN-O0-NEXT: buffer_store_dword v5, v6, s[0:3], 0 offen
1385 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1386 ; GCN-O0-NEXT: ; kill: def $vgpr1 killed $vgpr1 killed $vgpr1_vgpr2_vgpr3_vgpr4 killed $exec
1387 ; GCN-O0-NEXT: ; implicit-def: $sgpr4
1388 ; GCN-O0-NEXT: v_mov_b32_e32 v2, s4
1389 ; GCN-O0-NEXT: buffer_store_dword v1, v2, s[0:3], 0 offen
1390 ; GCN-O0-NEXT: s_waitcnt vmcnt(0)
1391 ; GCN-O0-NEXT: ; kill: killed $vgpr0
1392 ; GCN-O0-NEXT: s_xor_saveexec_b64 s[4:5], -1
1393 ; GCN-O0-NEXT: buffer_load_dword v0, off, s[0:3], s32 offset:72 ; 4-byte Folded Reload
1394 ; GCN-O0-NEXT: buffer_load_dword v4, off, s[0:3], s32 offset:76 ; 4-byte Folded Reload
1395 ; GCN-O0-NEXT: s_mov_b64 exec, s[4:5]
1396 ; GCN-O0-NEXT: s_waitcnt vmcnt(0) expcnt(0)
1397 ; GCN-O0-NEXT: s_setpc_b64 s[30:31]
1401 bb1: ; preds = %Flow1, %bb1, %bb
1402 %tmp = icmp slt i32 %arg, 519
1403 br i1 %tmp, label %bb2, label %bb1
1406 %tmp3 = icmp eq i32 %arg, 0
1407 br i1 %tmp3, label %bb4, label %bb10
1410 %tmp6 = load float, ptr addrspace(5) undef
1411 %tmp7 = fcmp olt float %tmp6, 0.0
1412 br i1 %tmp7, label %bb8, label %Flow
1415 %tmp9 = insertelement <4 x float> undef, float 0.0, i32 1
1418 Flow: ; preds = %bb8, %bb4
1419 %tmp8 = phi <4 x float> [ %tmp9, %bb8 ], [ zeroinitializer, %bb4 ]
1422 bb10: ; preds = %Flow, %bb2
1423 %tmp11 = phi <4 x float> [ zeroinitializer, %bb2 ], [ %tmp8, %Flow ]
1424 br i1 %tmp3, label %bb12, label %Flow1
1426 Flow1: ; preds = %bb10
1429 bb12: ; preds = %bb10
1430 store volatile <4 x float> %tmp11, ptr addrspace(5) undef, align 16
1434 declare i32 @llvm.amdgcn.workitem.id.x() #0
1435 declare void @llvm.amdgcn.s.barrier() #1
1437 attributes #0 = { nounwind readnone speculatable }
1438 attributes #1 = { nounwind convergent }
1439 attributes #2 = { nounwind }