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-NEXT: [[S_LOAD_DWORD_IMM:%[0-9]+]]:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM [[COPY]], 16, 0
13 ; GCN-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32_xm0 = S_AND_B32 [[S_LOAD_DWORD_IMM]], 255, implicit-def $scc
14 ; GCN-NEXT: dead %3:sreg_32_xm0 = S_AND_B32 65535, [[S_AND_B32_]], implicit-def $scc
15 ; GCN-NEXT: S_ENDPGM 0
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-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
31 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
32 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
33 ; GCN-NEXT: dead %0:sreg_64 = S_XOR_B64 [[S_AND_B64_]], [[COPY]], implicit-def dead $scc
34 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
35 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
36 ; GCN-NEXT: S_BRANCH %bb.1
39 ; GCN-NEXT: successors: %bb.2(0x80000000)
43 ; GCN-NEXT: S_ENDPGM 0
45 successors: %bb.1, %bb.2
47 %1:sreg_64 = SI_IF undef %0:sreg_64, %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
58 # We need to split the block for SI_END_CF, but
60 name: end_cf_split_block_end
61 tracksRegLiveness: true
63 ; GCN-LABEL: name: end_cf_split_block_end
65 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
66 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
68 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
69 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
70 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
71 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
72 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
73 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
74 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
75 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
76 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
77 ; GCN-NEXT: S_BRANCH %bb.2
80 ; GCN-NEXT: successors: %bb.2(0x80000000)
82 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
83 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
86 ; GCN-NEXT: S_ENDPGM 0
88 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
90 %0:vgpr_32 = COPY killed $vgpr0
91 %1:vgpr_32 = COPY killed $vgpr1
92 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
93 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
94 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
100 %6:sreg_64_xexec = COPY %5
101 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
109 name: end_cf_split_block_physreg_livein
110 tracksRegLiveness: true
112 ; GCN-LABEL: name: end_cf_split_block_physreg_livein
114 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
115 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
117 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
118 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
119 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
120 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
121 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
122 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
123 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
124 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
125 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
126 ; GCN-NEXT: S_BRANCH %bb.2
129 ; GCN-NEXT: successors: %bb.3(0x80000000)
130 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
132 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
134 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
137 ; GCN-NEXT: successors: %bb.2(0x80000000)
138 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
140 ; GCN-NEXT: S_SLEEP 3
141 ; GCN-NEXT: S_NOP 0, implicit $vgpr0, implicit $sgpr4_sgpr5
144 ; GCN-NEXT: S_ENDPGM 0
146 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
148 %0:vgpr_32 = COPY killed $vgpr0
149 %1:vgpr_32 = COPY killed $vgpr1
150 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
151 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
152 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
157 liveins: $vgpr0, $sgpr4_sgpr5
159 %6:sreg_64_xexec = COPY %5
161 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
163 S_NOP 0, implicit $vgpr0, implicit $sgpr4_sgpr5
171 name: end_cf_split_block_physreg_livein_liveout
172 tracksRegLiveness: true
174 ; GCN-LABEL: name: end_cf_split_block_physreg_livein_liveout
176 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
177 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x0000000000000003
179 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
180 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
181 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
182 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
183 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
184 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
185 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
186 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
187 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
188 ; GCN-NEXT: S_BRANCH %bb.2
191 ; GCN-NEXT: successors: %bb.3(0x80000000)
192 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x0000000000000003
194 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
195 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
198 ; GCN-NEXT: successors: %bb.2(0x80000000)
199 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9
201 ; GCN-NEXT: S_SLEEP 3
205 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x0000000000000003
207 ; GCN-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5, implicit $sgpr8_sgpr9_sgpr10_sgpr11
209 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x00000003
211 %0:vgpr_32 = COPY killed $vgpr0
212 %1:vgpr_32 = COPY killed $vgpr1
213 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
214 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
215 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
220 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x00000003
222 %6:sreg_64_xexec = COPY %5
223 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
228 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x00000003
229 S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5, implicit $sgpr8_sgpr9_sgpr10_sgpr11
234 name: end_cf_split_block_physreg_liveout
235 tracksRegLiveness: true
237 ; GCN-LABEL: name: end_cf_split_block_physreg_liveout
239 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
240 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
242 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
243 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
244 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
245 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
246 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
247 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
248 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
249 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
250 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
251 ; GCN-NEXT: S_BRANCH %bb.2
254 ; GCN-NEXT: successors: %bb.3(0x80000000)
256 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
257 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
260 ; GCN-NEXT: successors: %bb.2(0x80000000)
262 ; GCN-NEXT: $vgpr3 = V_MOV_B32_e32 0, implicit $exec
263 ; GCN-NEXT: $sgpr4_sgpr5 = S_MOV_B64 32
266 ; GCN-NEXT: liveins: $vgpr3, $sgpr4_sgpr5
268 ; GCN-NEXT: S_ENDPGM 0, implicit $vgpr3, implicit $sgpr4_sgpr5
270 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
272 %0:vgpr_32 = COPY killed $vgpr0
273 %1:vgpr_32 = COPY killed $vgpr1
274 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
275 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
276 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
282 %6:sreg_64_xexec = COPY %5
283 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
284 $vgpr3 = V_MOV_B32_e32 0, implicit $exec
285 $sgpr4_sgpr5 = S_MOV_B64 32
288 liveins: $vgpr3, $sgpr4_sgpr5
289 S_ENDPGM 0, implicit $vgpr3, implicit $sgpr4_sgpr5
294 name: end_cf_split_block_physreg_live_across_split
295 tracksRegLiveness: true
297 ; GCN-LABEL: name: end_cf_split_block_physreg_live_across_split
299 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
300 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
302 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
303 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
304 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
305 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
306 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
307 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
308 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
309 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
310 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
311 ; GCN-NEXT: S_BRANCH %bb.2
314 ; GCN-NEXT: successors: %bb.3(0x80000000)
315 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
317 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
318 ; GCN-NEXT: $sgpr4_sgpr5 = S_MOV_B64 32
319 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
322 ; GCN-NEXT: successors: %bb.2(0x80000000)
323 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
325 ; GCN-NEXT: S_SLEEP 3, implicit $sgpr4_sgpr5
329 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
331 ; GCN-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5
333 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
335 %0:vgpr_32 = COPY killed $vgpr0
336 %1:vgpr_32 = COPY killed $vgpr1
337 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
338 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
339 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
344 liveins: $vgpr0, $sgpr4_sgpr5
346 %6:sreg_64_xexec = COPY %5
347 $sgpr4_sgpr5 = S_MOV_B64 32
348 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
349 S_SLEEP 3, implicit $sgpr4_sgpr5
353 liveins: $vgpr0, $sgpr4_sgpr5
354 S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5
359 name: end_cf_split_block_process_next_inst
360 tracksRegLiveness: true
362 ; GCN-LABEL: name: end_cf_split_block_process_next_inst
364 ; GCN-NEXT: successors: %bb.1(0x80000000)
365 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $vgpr2
367 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
368 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
369 ; GCN-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
370 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
371 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_1:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY2]], implicit $exec
372 ; GCN-NEXT: dead %5:sreg_64_xexec = S_MOV_B64 0
375 ; GCN-NEXT: successors: %bb.3(0x80000000)
377 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[V_CMP_EQ_U32_e64_]]
378 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
381 ; GCN-NEXT: successors: %bb.2(0x80000000)
383 ; GCN-NEXT: [[COPY4:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
384 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY4]], [[V_CMP_EQ_U32_e64_1]], implicit-def dead $scc
385 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY4]], implicit-def dead $scc
386 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
387 ; GCN-NEXT: dead %8:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
388 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
391 ; GCN-NEXT: S_ENDPGM 0
393 liveins: $vgpr0, $vgpr1, $vgpr2
395 %0:vgpr_32 = COPY killed $vgpr0
396 %1:vgpr_32 = COPY killed $vgpr1
397 %2:vgpr_32 = COPY killed $vgpr2
398 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 %0, killed %1, implicit $exec
399 %4:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %2, implicit $exec
400 %5:sreg_64_xexec = S_MOV_B64 0
405 %6:sreg_64_xexec = COPY %3
406 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
407 %7:sreg_64_xexec = SI_IF %4, %bb.2, implicit-def $exec, implicit-def dead $scc, implicit $exec
408 %8:sreg_64_xexec = S_MOV_B64_term %7, implicit $exec