1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2 # RUN: llc -mtriple=amdgcn -mcpu=gfx803 -verify-machineinstrs -run-pass=si-fold-operands %s -o - | FileCheck -check-prefixes=CHECK,GFX8 %s
3 # RUN: llc -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass=si-fold-operands %s -o - | FileCheck -check-prefixes=CHECK,GFX9 %s
4 # RUN: llc -mtriple=amdgcn -mcpu=gfx1030 -mattr=+wavefrontsize64 -verify-machineinstrs -run-pass=si-fold-operands %s -o - | FileCheck -check-prefixes=CHECK,GFX10 %s
5 # RUN: llc -mtriple=amdgcn -mcpu=gfx1200 -mattr=+wavefrontsize64 -verify-machineinstrs -run-pass=si-fold-operands %s -o - | FileCheck -check-prefixes=CHECK,GFX10 %s
9 tracksRegLiveness: true
11 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
14 ; CHECK-LABEL: name: copy_undef
15 ; CHECK: [[COPY:%[0-9]+]]:vgpr_32 = COPY undef %2:sreg_32
16 ; CHECK-NEXT: SI_RETURN implicit [[COPY]]
17 %0:sreg_32 = S_MOV_B32 %stack.0
18 %2:vgpr_32 = COPY undef %1:sreg_32
23 name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr
24 tracksRegLiveness: true
26 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
29 ; GFX8-LABEL: name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr
30 ; GFX8: [[V_ADD_CO_U32_e32_:%[0-9]+]]:vgpr_32 = nuw V_ADD_CO_U32_e32 128, %stack.0, implicit-def dead $vcc, implicit $exec
31 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e32_]]
33 ; GFX9-LABEL: name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr
34 ; GFX9: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = nuw V_ADD_U32_e32 128, %stack.0, implicit $exec
35 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]]
37 ; GFX10-LABEL: name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr
38 ; GFX10: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = nuw V_ADD_U32_e32 128, %stack.0, implicit $exec
39 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]]
40 %0:sreg_32 = S_MOV_B32 %stack.0
41 %1:sreg_32 = nuw S_ADD_I32 %0, 128, implicit-def dead $scc
47 name: fold_s_add_i32__const_copy_mov_fi_to_virt_vgpr
48 tracksRegLiveness: true
50 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
53 ; GFX8-LABEL: name: fold_s_add_i32__const_copy_mov_fi_to_virt_vgpr
54 ; GFX8: [[V_ADD_CO_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_CO_U32_e32 128, %stack.0, implicit-def dead $vcc, implicit $exec
55 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e32_]]
57 ; GFX9-LABEL: name: fold_s_add_i32__const_copy_mov_fi_to_virt_vgpr
58 ; GFX9: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 128, %stack.0, implicit $exec
59 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]]
61 ; GFX10-LABEL: name: fold_s_add_i32__const_copy_mov_fi_to_virt_vgpr
62 ; GFX10: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 128, %stack.0, implicit $exec
63 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]]
64 %0:sreg_32 = S_MOV_B32 %stack.0
65 %1:sreg_32 = S_ADD_I32 128, %0, implicit-def dead $scc
71 name: fold_s_add_i32__fi_imm_copy_to_virt_vgpr
72 tracksRegLiveness: true
74 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
77 ; GFX8-LABEL: name: fold_s_add_i32__fi_imm_copy_to_virt_vgpr
78 ; GFX8: [[V_ADD_CO_U32_e64_:%[0-9]+]]:vgpr_32, dead [[V_ADD_CO_U32_e64_1:%[0-9]+]]:sreg_64 = nuw V_ADD_CO_U32_e64 64, %stack.0, 0, implicit $exec
79 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e64_]]
81 ; GFX9-LABEL: name: fold_s_add_i32__fi_imm_copy_to_virt_vgpr
82 ; GFX9: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = nuw V_ADD_U32_e64 64, %stack.0, 0, implicit $exec
83 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
85 ; GFX10-LABEL: name: fold_s_add_i32__fi_imm_copy_to_virt_vgpr
86 ; GFX10: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = nuw V_ADD_U32_e64 64, %stack.0, 0, implicit $exec
87 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
88 %0:sreg_32 = nuw S_ADD_I32 %stack.0, 64, implicit-def dead $scc
94 name: fold_s_add_i32__imm_fi_copy_to_virt_vgpr
95 tracksRegLiveness: true
97 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
100 ; GFX8-LABEL: name: fold_s_add_i32__imm_fi_copy_to_virt_vgpr
101 ; GFX8: [[V_ADD_CO_U32_e64_:%[0-9]+]]:vgpr_32, dead [[V_ADD_CO_U32_e64_1:%[0-9]+]]:sreg_64 = nuw V_ADD_CO_U32_e64 64, %stack.0, 0, implicit $exec
102 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e64_]]
104 ; GFX9-LABEL: name: fold_s_add_i32__imm_fi_copy_to_virt_vgpr
105 ; GFX9: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = nuw V_ADD_U32_e64 64, %stack.0, 0, implicit $exec
106 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
108 ; GFX10-LABEL: name: fold_s_add_i32__imm_fi_copy_to_virt_vgpr
109 ; GFX10: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = nuw V_ADD_U32_e64 64, %stack.0, 0, implicit $exec
110 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
111 %0:sreg_32 = nuw S_ADD_I32 64, %stack.0, implicit-def dead $scc
113 SI_RETURN implicit %1
117 name: fold_s_add_i32__mov_fi_const_copy_to_phys_vgpr
118 tracksRegLiveness: true
120 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
123 ; CHECK-LABEL: name: fold_s_add_i32__mov_fi_const_copy_to_phys_vgpr
124 ; CHECK: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 %stack.0, 128, implicit-def dead $scc
125 ; CHECK-NEXT: $vgpr0 = COPY [[S_ADD_I32_]]
126 ; CHECK-NEXT: SI_RETURN implicit $vgpr0
127 %0:sreg_32 = S_MOV_B32 %stack.0
128 %1:sreg_32 = S_ADD_I32 %0, 128, implicit-def dead $scc
130 SI_RETURN implicit $vgpr0
134 name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr_live_vcc
135 tracksRegLiveness: true
137 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
141 ; GFX8-LABEL: name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr_live_vcc
142 ; GFX8: liveins: $vcc
144 ; GFX8-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 %stack.0, 128, implicit-def dead $scc
145 ; GFX8-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY [[S_ADD_I32_]]
146 ; GFX8-NEXT: SI_RETURN implicit [[COPY]], implicit $vcc
148 ; GFX9-LABEL: name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr_live_vcc
149 ; GFX9: liveins: $vcc
151 ; GFX9-NEXT: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 128, %stack.0, implicit $exec
152 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]], implicit $vcc
154 ; GFX10-LABEL: name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr_live_vcc
155 ; GFX10: liveins: $vcc
157 ; GFX10-NEXT: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 128, %stack.0, implicit $exec
158 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]], implicit $vcc
159 %0:sreg_32 = S_MOV_B32 %stack.0
160 %1:sreg_32 = S_ADD_I32 %0, 128, implicit-def dead $scc
162 SI_RETURN implicit %2, implicit $vcc
166 name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr_live_scc
167 tracksRegLiveness: true
170 localFrameSize: 16384
172 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
175 ; CHECK-LABEL: name: fold_s_add_i32__mov_fi_const_copy_to_virt_vgpr_live_scc
176 ; CHECK: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 %stack.0, 128, implicit-def $scc
177 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY [[S_ADD_I32_]]
178 ; CHECK-NEXT: SI_RETURN implicit [[COPY]], implicit $scc
179 %0:sreg_32 = S_MOV_B32 %stack.0
180 %1:sreg_32 = S_ADD_I32 %0, 128, implicit-def $scc
182 SI_RETURN implicit %2, implicit $scc
186 name: fold_s_add_i32__mov_fi_reg_copy_to_virt_vgpr
187 tracksRegLiveness: true
189 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
194 ; GFX8-LABEL: name: fold_s_add_i32__mov_fi_reg_copy_to_virt_vgpr
195 ; GFX8: liveins: $sgpr8
197 ; GFX8-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
198 ; GFX8-NEXT: [[V_ADD_CO_U32_e64_:%[0-9]+]]:vgpr_32, dead [[V_ADD_CO_U32_e64_1:%[0-9]+]]:sreg_64 = V_ADD_CO_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
199 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e64_]]
201 ; GFX9-LABEL: name: fold_s_add_i32__mov_fi_reg_copy_to_virt_vgpr
202 ; GFX9: liveins: $sgpr8
204 ; GFX9-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
205 ; GFX9-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
206 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
208 ; GFX10-LABEL: name: fold_s_add_i32__mov_fi_reg_copy_to_virt_vgpr
209 ; GFX10: liveins: $sgpr8
211 ; GFX10-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
212 ; GFX10-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
213 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
214 %0:sreg_32 = COPY $sgpr8
215 %1:sreg_32 = S_MOV_B32 %stack.0
216 %2:sreg_32 = S_ADD_I32 %0, %1, implicit-def dead $scc
218 SI_RETURN implicit %3
223 name: fold_s_add_i32__reg_copy_mov_fi_to_virt_vgpr
224 tracksRegLiveness: true
226 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
231 ; GFX8-LABEL: name: fold_s_add_i32__reg_copy_mov_fi_to_virt_vgpr
232 ; GFX8: liveins: $sgpr8
234 ; GFX8-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
235 ; GFX8-NEXT: [[V_ADD_CO_U32_e64_:%[0-9]+]]:vgpr_32, dead [[V_ADD_CO_U32_e64_1:%[0-9]+]]:sreg_64 = V_ADD_CO_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
236 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e64_]]
238 ; GFX9-LABEL: name: fold_s_add_i32__reg_copy_mov_fi_to_virt_vgpr
239 ; GFX9: liveins: $sgpr8
241 ; GFX9-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
242 ; GFX9-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
243 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
245 ; GFX10-LABEL: name: fold_s_add_i32__reg_copy_mov_fi_to_virt_vgpr
246 ; GFX10: liveins: $sgpr8
248 ; GFX10-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
249 ; GFX10-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
250 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
251 %0:sreg_32 = COPY $sgpr8
252 %1:sreg_32 = S_MOV_B32 %stack.0
253 %2:sreg_32 = S_ADD_I32 %1, %0, implicit-def dead $scc
255 SI_RETURN implicit %3
259 name: fold_s_add_i32__fi_fi_copy_to_virt_vgpr
260 tracksRegLiveness: true
262 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
263 - { id: 1, size: 16384, alignment: 4, local-offset: 0 }
266 ; CHECK-LABEL: name: fold_s_add_i32__fi_fi_copy_to_virt_vgpr
267 ; CHECK: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 %stack.0, %stack.1, implicit-def dead $scc
268 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY [[COPY]]
269 ; CHECK-NEXT: SI_RETURN implicit [[COPY]]
270 %0:sreg_32 = S_ADD_I32 %stack.0, %stack.1, implicit-def dead $scc
272 SI_RETURN implicit %1
276 name: fold_s_add_i32__fi_const_copy_to_virt_vgpr
277 tracksRegLiveness: true
279 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
282 ; GFX8-LABEL: name: fold_s_add_i32__fi_const_copy_to_virt_vgpr
283 ; GFX8: [[V_ADD_CO_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_CO_U32_e32 128, %stack.0, implicit-def dead $vcc, implicit $exec
284 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e32_]]
286 ; GFX9-LABEL: name: fold_s_add_i32__fi_const_copy_to_virt_vgpr
287 ; GFX9: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 128, %stack.0, implicit $exec
288 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]]
290 ; GFX10-LABEL: name: fold_s_add_i32__fi_const_copy_to_virt_vgpr
291 ; GFX10: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 128, %stack.0, implicit $exec
292 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]]
293 %0:sreg_32 = S_ADD_I32 %stack.0, 128, implicit-def dead $scc
295 SI_RETURN implicit %1
299 name: fold_s_add_i32__const_fi_copy_to_virt_vgpr
300 tracksRegLiveness: true
302 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
305 ; GFX8-LABEL: name: fold_s_add_i32__const_fi_copy_to_virt_vgpr
306 ; GFX8: [[V_ADD_CO_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_CO_U32_e32 128, %stack.0, implicit-def dead $vcc, implicit $exec
307 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e32_]]
309 ; GFX9-LABEL: name: fold_s_add_i32__const_fi_copy_to_virt_vgpr
310 ; GFX9: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 128, %stack.0, implicit $exec
311 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]]
313 ; GFX10-LABEL: name: fold_s_add_i32__const_fi_copy_to_virt_vgpr
314 ; GFX10: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 128, %stack.0, implicit $exec
315 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e32_]]
316 %0:sreg_32 = S_ADD_I32 128, %stack.0, implicit-def dead $scc
318 SI_RETURN implicit %1
322 name: fold_s_add_i32__fi_reg_copy_to_virt_vgpr
323 tracksRegLiveness: true
325 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
329 ; GFX8-LABEL: name: fold_s_add_i32__fi_reg_copy_to_virt_vgpr
330 ; GFX8: liveins: $sgpr8
332 ; GFX8-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
333 ; GFX8-NEXT: [[V_ADD_CO_U32_e64_:%[0-9]+]]:vgpr_32, dead [[V_ADD_CO_U32_e64_1:%[0-9]+]]:sreg_64 = V_ADD_CO_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
334 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e64_]]
336 ; GFX9-LABEL: name: fold_s_add_i32__fi_reg_copy_to_virt_vgpr
337 ; GFX9: liveins: $sgpr8
339 ; GFX9-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
340 ; GFX9-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
341 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
343 ; GFX10-LABEL: name: fold_s_add_i32__fi_reg_copy_to_virt_vgpr
344 ; GFX10: liveins: $sgpr8
346 ; GFX10-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
347 ; GFX10-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
348 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
349 %0:sreg_32 = COPY $sgpr8
350 %1:sreg_32 = S_ADD_I32 %stack.0, %0, implicit-def dead $scc
352 SI_RETURN implicit %2
356 name: fold_s_add_i32__reg_fi_copy_to_virt_vgpr
357 tracksRegLiveness: true
359 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
363 ; GFX8-LABEL: name: fold_s_add_i32__reg_fi_copy_to_virt_vgpr
364 ; GFX8: liveins: $sgpr8
366 ; GFX8-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
367 ; GFX8-NEXT: [[V_ADD_CO_U32_e64_:%[0-9]+]]:vgpr_32, dead [[V_ADD_CO_U32_e64_1:%[0-9]+]]:sreg_64 = V_ADD_CO_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
368 ; GFX8-NEXT: SI_RETURN implicit [[V_ADD_CO_U32_e64_]]
370 ; GFX9-LABEL: name: fold_s_add_i32__reg_fi_copy_to_virt_vgpr
371 ; GFX9: liveins: $sgpr8
373 ; GFX9-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
374 ; GFX9-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
375 ; GFX9-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
377 ; GFX10-LABEL: name: fold_s_add_i32__reg_fi_copy_to_virt_vgpr
378 ; GFX10: liveins: $sgpr8
380 ; GFX10-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
381 ; GFX10-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], %stack.0, 0, implicit $exec
382 ; GFX10-NEXT: SI_RETURN implicit [[V_ADD_U32_e64_]]
383 %0:sreg_32 = COPY $sgpr8
384 %1:sreg_32 = S_ADD_I32 %0, %stack.0, implicit-def dead $scc
386 SI_RETURN implicit %2
390 name: fold_s_or_b32__mov_fi_const_copy_to_virt_vgpr
391 tracksRegLiveness: true
393 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
396 ; CHECK-LABEL: name: fold_s_or_b32__mov_fi_const_copy_to_virt_vgpr
397 ; CHECK: [[V_OR_B32_e32_:%[0-9]+]]:vgpr_32 = V_OR_B32_e32 128, %stack.0, implicit $exec
398 ; CHECK-NEXT: SI_RETURN implicit [[V_OR_B32_e32_]]
399 %0:sreg_32 = S_MOV_B32 %stack.0
400 %1:sreg_32 = S_OR_B32 %0, 128, implicit-def dead $scc
402 SI_RETURN implicit %2
406 name: fold_s_or_b32__const_copy_mov_fi_to_virt_vgpr
407 tracksRegLiveness: true
409 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
412 ; CHECK-LABEL: name: fold_s_or_b32__const_copy_mov_fi_to_virt_vgpr
413 ; CHECK: [[V_OR_B32_e32_:%[0-9]+]]:vgpr_32 = V_OR_B32_e32 128, %stack.0, implicit $exec
414 ; CHECK-NEXT: SI_RETURN implicit [[V_OR_B32_e32_]]
415 %0:sreg_32 = S_MOV_B32 %stack.0
416 %1:sreg_32 = S_OR_B32 128, %0, implicit-def dead $scc
418 SI_RETURN implicit %2
422 name: fold_s_or_b32__fi_imm_copy_to_virt_vgpr
423 tracksRegLiveness: true
425 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
428 ; CHECK-LABEL: name: fold_s_or_b32__fi_imm_copy_to_virt_vgpr
429 ; CHECK: %1:vgpr_32 = disjoint V_OR_B32_e64 64, %stack.0, implicit $exec
430 ; CHECK-NEXT: SI_RETURN implicit %1
431 %0:sreg_32 = disjoint S_OR_B32 %stack.0, 64, implicit-def dead $scc
433 SI_RETURN implicit %1
437 name: fold_s_or_b32__imm_fi_copy_to_virt_vgpr
438 tracksRegLiveness: true
440 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
443 ; CHECK-LABEL: name: fold_s_or_b32__imm_fi_copy_to_virt_vgpr
444 ; CHECK: %1:vgpr_32 = disjoint V_OR_B32_e64 64, %stack.0, implicit $exec
445 ; CHECK-NEXT: SI_RETURN implicit %1
446 %0:sreg_32 = disjoint S_OR_B32 64, %stack.0, implicit-def dead $scc
448 SI_RETURN implicit %1
452 name: fold_s_and_b32__fi_imm_copy_to_virt_vgpr
453 tracksRegLiveness: true
455 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
458 ; CHECK-LABEL: name: fold_s_and_b32__fi_imm_copy_to_virt_vgpr
459 ; CHECK: [[V_AND_B32_e64_:%[0-9]+]]:vgpr_32 = V_AND_B32_e64 64, %stack.0, implicit $exec
460 ; CHECK-NEXT: SI_RETURN implicit [[V_AND_B32_e64_]]
461 %0:sreg_32 = S_AND_B32 %stack.0, 64, implicit-def dead $scc
463 SI_RETURN implicit %1
467 name: fold_s_and_b32__fi_const_copy_to_virt_vgpr
468 tracksRegLiveness: true
470 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
473 ; CHECK-LABEL: name: fold_s_and_b32__fi_const_copy_to_virt_vgpr
474 ; CHECK: [[V_AND_B32_e32_:%[0-9]+]]:vgpr_32 = V_AND_B32_e32 128, %stack.0, implicit $exec
475 ; CHECK-NEXT: SI_RETURN implicit [[V_AND_B32_e32_]]
476 %0:sreg_32 = S_AND_B32 %stack.0, 128, implicit-def dead $scc
478 SI_RETURN implicit %1
482 name: fold_s_mul_i32__fi_imm_copy_to_virt_vgpr
483 tracksRegLiveness: true
485 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
488 ; CHECK-LABEL: name: fold_s_mul_i32__fi_imm_copy_to_virt_vgpr
489 ; CHECK: [[V_MUL_LO_U32_e64_:%[0-9]+]]:vgpr_32 = V_MUL_LO_U32_e64 64, %stack.0, implicit $exec
490 ; CHECK-NEXT: SI_RETURN implicit [[V_MUL_LO_U32_e64_]]
491 %0:sreg_32 = S_MUL_I32 %stack.0, 64, implicit-def dead $scc
493 SI_RETURN implicit %1
497 name: fold_s_mul_i32__fi_reg_copy_to_virt_vgpr
498 tracksRegLiveness: true
500 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
504 ; CHECK-LABEL: name: fold_s_mul_i32__fi_reg_copy_to_virt_vgpr
505 ; CHECK: liveins: $sgpr4
507 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr4
508 ; CHECK-NEXT: [[V_MUL_LO_U32_e64_:%[0-9]+]]:vgpr_32 = V_MUL_LO_U32_e64 [[COPY]], %stack.0, implicit $exec
509 ; CHECK-NEXT: SI_RETURN implicit [[V_MUL_LO_U32_e64_]]
510 %0:sreg_32 = COPY $sgpr4
511 %1:sreg_32 = S_MUL_I32 %stack.0, %0, implicit-def dead $scc
513 SI_RETURN implicit %2
517 name: fold_s_and_b32__mov_fi_const_copy_to_virt_vgpr
518 tracksRegLiveness: true
520 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
523 ; CHECK-LABEL: name: fold_s_and_b32__mov_fi_const_copy_to_virt_vgpr
524 ; CHECK: [[V_AND_B32_e32_:%[0-9]+]]:vgpr_32 = V_AND_B32_e32 128, %stack.0, implicit $exec
525 ; CHECK-NEXT: SI_RETURN implicit [[V_AND_B32_e32_]]
526 %0:sreg_32 = S_MOV_B32 %stack.0
527 %1:sreg_32 = S_AND_B32 %0, 128, implicit-def dead $scc
529 SI_RETURN implicit %2
532 # Physreg copy of %2 to $vgpr0 should not be erased
534 name: fold_fi_into_s_or_b32_user_is_physreg_copy
535 tracksRegLiveness: true
537 - { id: 0, size: 16, alignment: 16 }
539 scratchRSrcReg: '$sgpr0_sgpr1_sgpr2_sgpr3'
540 frameOffsetReg: '$sgpr33'
541 stackPtrOffsetReg: '$sgpr32'
543 ; CHECK-LABEL: name: fold_fi_into_s_or_b32_user_is_physreg_copy
545 ; CHECK-NEXT: successors: %bb.1(0x80000000)
546 ; CHECK-NEXT: liveins: $vgpr0_vgpr1
548 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
549 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 %stack.0, 4, implicit-def dead $scc
550 ; CHECK-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 $exec
553 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
555 ; CHECK-NEXT: [[V_READFIRSTLANE_B32_:%[0-9]+]]:sgpr_32 = V_READFIRSTLANE_B32 [[COPY]].sub0, implicit $exec
556 ; CHECK-NEXT: [[V_READFIRSTLANE_B32_1:%[0-9]+]]:sgpr_32 = V_READFIRSTLANE_B32 [[COPY]].sub1, implicit $exec
557 ; CHECK-NEXT: [[REG_SEQUENCE:%[0-9]+]]:sgpr_64 = REG_SEQUENCE [[V_READFIRSTLANE_B32_]], %subreg.sub0, [[V_READFIRSTLANE_B32_1]], %subreg.sub1
558 ; CHECK-NEXT: [[V_CMP_EQ_U64_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U64_e64 [[REG_SEQUENCE]], [[COPY]], implicit $exec
559 ; CHECK-NEXT: [[S_AND_SAVEEXEC_B64_:%[0-9]+]]:sreg_64_xexec = S_AND_SAVEEXEC_B64 killed [[V_CMP_EQ_U64_e64_]], implicit-def $exec, implicit-def $scc, implicit $exec
560 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
561 ; CHECK-NEXT: $vgpr0 = COPY [[S_ADD_I32_]]
562 ; CHECK-NEXT: $sgpr30_sgpr31 = SI_CALL [[REG_SEQUENCE]], 0, csr_amdgpu, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit $vgpr0
563 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
564 ; CHECK-NEXT: $exec = S_XOR_B64_term $exec, [[S_AND_SAVEEXEC_B64_]], implicit-def $scc
565 ; CHECK-NEXT: SI_WATERFALL_LOOP %bb.1, implicit $exec
568 ; CHECK-NEXT: $exec = S_MOV_B64 [[S_MOV_B64_]]
569 ; CHECK-NEXT: SI_RETURN
571 liveins: $vgpr0_vgpr1
573 %0:vreg_64 = COPY $vgpr0_vgpr1
574 %1:sreg_32 = S_MOV_B32 %stack.0
575 %2:sreg_32 = S_ADD_I32 killed %1, 4, implicit-def dead $scc
576 %3:sreg_64_xexec = S_MOV_B64 $exec
579 %4:sgpr_32 = V_READFIRSTLANE_B32 %0.sub0, implicit $exec
580 %5:sgpr_32 = V_READFIRSTLANE_B32 %0.sub1, implicit $exec
581 %6:sgpr_64 = REG_SEQUENCE %4, %subreg.sub0, %5, %subreg.sub1
582 %7:sreg_64_xexec = V_CMP_EQ_U64_e64 %6, %0, implicit $exec
583 %8:sreg_64_xexec = S_AND_SAVEEXEC_B64 killed %7, implicit-def $exec, implicit-def $scc, implicit $exec
584 ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
586 $sgpr30_sgpr31 = SI_CALL %6, 0, csr_amdgpu, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit $vgpr0
587 ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
588 $exec = S_XOR_B64_term $exec, %8, implicit-def $scc
589 SI_WATERFALL_LOOP %bb.1, implicit $exec