1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -run-pass=liveintervals,si-lower-control-flow,si-lower-control-flow -verify-machineinstrs %s -o - | FileCheck -check-prefixes=GCN %s
4 # Check that assert is not triggered
7 name: si-lower-control-flow
10 ; GCN-LABEL: name: si-lower-control-flow
11 ; GCN: [[COPY:%[0-9]+]]:sgpr_64 = COPY $sgpr4_sgpr5
12 ; GCN: [[S_LOAD_DWORD_IMM:%[0-9]+]]:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM [[COPY]], 16, 0
13 ; GCN: [[S_AND_B32_:%[0-9]+]]:sreg_32_xm0 = S_AND_B32 [[S_LOAD_DWORD_IMM]], 255, implicit-def $scc
14 ; GCN: dead %3:sreg_32_xm0 = S_AND_B32 65535, [[S_AND_B32_]], implicit-def $scc
16 %0:sgpr_64 = COPY $sgpr4_sgpr5
17 %1:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM %0, 16, 0
18 %2:sreg_32_xm0 = S_AND_B32 %1, 255, implicit-def $scc
19 %3:sreg_32_xm0 = S_AND_B32 65535, %2, implicit-def $scc
24 name: preserve_undef_flag_si_if_src
25 tracksRegLiveness: true
27 ; GCN-LABEL: name: preserve_undef_flag_si_if_src
29 ; GCN: successors: %bb.1(0x40000000), %bb.2(0x40000000)
30 ; GCN: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
31 ; GCN: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
32 ; GCN: [[S_XOR_B64_:%[0-9]+]]:sreg_64 = S_XOR_B64 [[S_AND_B64_]], [[COPY]], implicit-def dead $scc
33 ; GCN: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
34 ; GCN: S_CBRANCH_EXECZ %bb.2, implicit $exec
37 ; GCN: successors: %bb.2(0x80000000)
41 successors: %bb.1, %bb.2
43 %1:sreg_64 = SI_IF undef %0:sreg_64, %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
54 # We need to split the block for SI_END_CF, but
56 name: end_cf_split_block_end
57 tracksRegLiveness: true
59 ; GCN-LABEL: name: end_cf_split_block_end
61 ; GCN: successors: %bb.1(0x40000000), %bb.2(0x40000000)
62 ; GCN: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
63 ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
64 ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
65 ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
66 ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
67 ; GCN: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
68 ; GCN: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
69 ; GCN: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
70 ; GCN: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
71 ; GCN: S_CBRANCH_EXECZ %bb.1, implicit $exec
74 ; GCN: successors: %bb.2(0x80000000)
75 ; GCN: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
76 ; GCN: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
80 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
82 %0:vgpr_32 = COPY killed $vgpr0
83 %1:vgpr_32 = COPY killed $vgpr1
84 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
85 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
86 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
92 %6:sreg_64_xexec = COPY %5
93 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
101 name: end_cf_split_block_physreg_livein
102 tracksRegLiveness: true
104 ; GCN-LABEL: name: end_cf_split_block_physreg_livein
106 ; GCN: successors: %bb.1(0x40000000), %bb.2(0x40000000)
107 ; GCN: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
108 ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
109 ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
110 ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
111 ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
112 ; GCN: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
113 ; GCN: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
114 ; GCN: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
115 ; GCN: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
116 ; GCN: S_CBRANCH_EXECZ %bb.1, implicit $exec
117 ; GCN: S_BRANCH %bb.2
119 ; GCN: successors: %bb.3(0x80000000)
120 ; GCN: liveins: $vgpr0, $sgpr4_sgpr5
121 ; GCN: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
123 ; GCN: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
125 ; GCN: successors: %bb.2(0x80000000)
126 ; GCN: liveins: $vgpr0, $sgpr4_sgpr5
128 ; GCN: S_NOP 0, implicit $vgpr0, implicit $sgpr4_sgpr5
132 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
134 %0:vgpr_32 = COPY killed $vgpr0
135 %1:vgpr_32 = COPY killed $vgpr1
136 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
137 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
138 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
143 liveins: $vgpr0, $sgpr4_sgpr5
145 %6:sreg_64_xexec = COPY %5
147 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
149 S_NOP 0, implicit $vgpr0, implicit $sgpr4_sgpr5
157 name: end_cf_split_block_physreg_livein_liveout
158 tracksRegLiveness: true
160 ; GCN-LABEL: name: end_cf_split_block_physreg_livein_liveout
162 ; GCN: successors: %bb.1(0x40000000), %bb.2(0x40000000)
163 ; GCN: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x0000000000000003
164 ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
165 ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
166 ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
167 ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
168 ; GCN: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
169 ; GCN: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
170 ; GCN: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
171 ; GCN: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
172 ; GCN: S_CBRANCH_EXECZ %bb.1, implicit $exec
173 ; GCN: S_BRANCH %bb.2
175 ; GCN: successors: %bb.3(0x80000000)
176 ; GCN: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x0000000000000003
177 ; GCN: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
178 ; GCN: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
180 ; GCN: successors: %bb.2(0x80000000)
181 ; GCN: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9
185 ; GCN: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x0000000000000003
186 ; GCN: S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5, implicit $sgpr8_sgpr9_sgpr10_sgpr11
188 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x00000003
190 %0:vgpr_32 = COPY killed $vgpr0
191 %1:vgpr_32 = COPY killed $vgpr1
192 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
193 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
194 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
199 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x00000003
201 %6:sreg_64_xexec = COPY %5
202 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
207 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x00000003
208 S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5, implicit $sgpr8_sgpr9_sgpr10_sgpr11
213 name: end_cf_split_block_physreg_liveout
214 tracksRegLiveness: true
216 ; GCN-LABEL: name: end_cf_split_block_physreg_liveout
218 ; GCN: successors: %bb.1(0x40000000), %bb.2(0x40000000)
219 ; GCN: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
220 ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
221 ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
222 ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
223 ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
224 ; GCN: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
225 ; GCN: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
226 ; GCN: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
227 ; GCN: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
228 ; GCN: S_CBRANCH_EXECZ %bb.1, implicit $exec
229 ; GCN: S_BRANCH %bb.2
231 ; GCN: successors: %bb.3(0x80000000)
232 ; GCN: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
233 ; GCN: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
235 ; GCN: successors: %bb.2(0x80000000)
236 ; GCN: $vgpr3 = V_MOV_B32_e32 0, implicit $exec
237 ; GCN: $sgpr4_sgpr5 = S_MOV_B64 32
239 ; GCN: liveins: $vgpr3, $sgpr4_sgpr5
240 ; GCN: S_ENDPGM 0, implicit $vgpr3, implicit $sgpr4_sgpr5
242 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
244 %0:vgpr_32 = COPY killed $vgpr0
245 %1:vgpr_32 = COPY killed $vgpr1
246 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
247 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
248 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
254 %6:sreg_64_xexec = COPY %5
255 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
256 $vgpr3 = V_MOV_B32_e32 0, implicit $exec
257 $sgpr4_sgpr5 = S_MOV_B64 32
260 liveins: $vgpr3, $sgpr4_sgpr5
261 S_ENDPGM 0, implicit $vgpr3, implicit $sgpr4_sgpr5
266 name: end_cf_split_block_physreg_live_across_split
267 tracksRegLiveness: true
269 ; GCN-LABEL: name: end_cf_split_block_physreg_live_across_split
271 ; GCN: successors: %bb.1(0x40000000), %bb.2(0x40000000)
272 ; GCN: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
273 ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
274 ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
275 ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
276 ; GCN: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
277 ; GCN: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
278 ; GCN: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
279 ; GCN: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
280 ; GCN: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
281 ; GCN: S_CBRANCH_EXECZ %bb.1, implicit $exec
282 ; GCN: S_BRANCH %bb.2
284 ; GCN: successors: %bb.3(0x80000000)
285 ; GCN: liveins: $vgpr0, $sgpr4_sgpr5
286 ; GCN: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
287 ; GCN: $sgpr4_sgpr5 = S_MOV_B64 32
288 ; GCN: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
290 ; GCN: successors: %bb.2(0x80000000)
291 ; GCN: liveins: $vgpr0, $sgpr4_sgpr5
292 ; GCN: S_SLEEP 3, implicit $sgpr4_sgpr5
295 ; GCN: liveins: $vgpr0, $sgpr4_sgpr5
296 ; GCN: S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5
298 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
300 %0:vgpr_32 = COPY killed $vgpr0
301 %1:vgpr_32 = COPY killed $vgpr1
302 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
303 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
304 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
309 liveins: $vgpr0, $sgpr4_sgpr5
311 %6:sreg_64_xexec = COPY %5
312 $sgpr4_sgpr5 = S_MOV_B64 32
313 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
314 S_SLEEP 3, implicit $sgpr4_sgpr5
318 liveins: $vgpr0, $sgpr4_sgpr5
319 S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5
324 name: end_cf_split_block_process_next_inst
325 tracksRegLiveness: true
327 ; GCN-LABEL: name: end_cf_split_block_process_next_inst
329 ; GCN: successors: %bb.1(0x80000000)
330 ; GCN: liveins: $vgpr0, $vgpr1, $vgpr2
331 ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
332 ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
333 ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
334 ; GCN: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
335 ; GCN: [[V_CMP_EQ_U32_e64_1:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY2]], implicit $exec
336 ; GCN: dead %5:sreg_64_xexec = S_MOV_B64 0
338 ; GCN: successors: %bb.3(0x80000000)
339 ; GCN: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[V_CMP_EQ_U32_e64_]]
340 ; GCN: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
342 ; GCN: successors: %bb.2(0x80000000)
343 ; GCN: [[COPY4:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
344 ; GCN: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY4]], [[V_CMP_EQ_U32_e64_1]], implicit-def dead $scc
345 ; GCN: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY4]], implicit-def dead $scc
346 ; GCN: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
347 ; GCN: dead %8:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
348 ; GCN: S_CBRANCH_EXECZ %bb.2, implicit $exec
352 liveins: $vgpr0, $vgpr1, $vgpr2
354 %0:vgpr_32 = COPY killed $vgpr0
355 %1:vgpr_32 = COPY killed $vgpr1
356 %2:vgpr_32 = COPY killed $vgpr2
357 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 %0, killed %1, implicit $exec
358 %4:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %2, implicit $exec
359 %5:sreg_64_xexec = S_MOV_B64 0
364 %6:sreg_64_xexec = COPY %3
365 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
366 %7:sreg_64_xexec = SI_IF %4, %bb.2, implicit-def $exec, implicit-def dead $scc, implicit $exec
367 %8:sreg_64_xexec = S_MOV_B64_term %7, implicit $exec