1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2 # RUN: llc -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass=si-fold-operands %s -o - | FileCheck -check-prefixes=CHECK,GFX9 %s
3 # RUN: llc -mtriple=amdgcn -mcpu=gfx1030 -mattr=+wavefrontsize64 -verify-machineinstrs -run-pass=si-fold-operands %s -o - | FileCheck -check-prefixes=CHECK,GFX10 %s
4 # RUN: llc -mtriple=amdgcn -mcpu=gfx1200 -mattr=+wavefrontsize64 -verify-machineinstrs -run-pass=si-fold-operands %s -o - | FileCheck -check-prefixes=CHECK,GFX12 %s
7 name: fold_frame_index__s_add_i32__fi_const
8 tracksRegLiveness: true
13 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
16 ; CHECK-LABEL: name: fold_frame_index__s_add_i32__fi_const
17 ; CHECK: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 %stack.0, 128, implicit-def $scc
18 ; CHECK-NEXT: $sgpr4 = COPY [[S_ADD_I32_]]
19 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
20 %0:sreg_32 = S_MOV_B32 %stack.0
21 %1:sreg_32 = S_ADD_I32 %0, 128, implicit-def $scc
23 SI_RETURN implicit $sgpr4
27 name: fold_frame_index__s_add_i32__const_fi
28 tracksRegLiveness: true
33 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
36 ; CHECK-LABEL: name: fold_frame_index__s_add_i32__const_fi
37 ; CHECK: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 128, %stack.0, implicit-def $scc
38 ; CHECK-NEXT: $sgpr4 = COPY [[S_ADD_I32_]]
39 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
40 %0:sreg_32 = S_MOV_B32 %stack.0
41 %1:sreg_32 = S_ADD_I32 128, %0, implicit-def $scc
43 SI_RETURN implicit $sgpr4
47 name: fold_frame_index__s_add_i32__materializedconst_fi
48 tracksRegLiveness: true
53 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
56 ; CHECK-LABEL: name: fold_frame_index__s_add_i32__materializedconst_fi
57 ; CHECK: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 256, %stack.0, implicit-def $scc
58 ; CHECK-NEXT: $sgpr4 = COPY [[S_ADD_I32_]]
59 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
60 %0:sreg_32 = S_MOV_B32 256
61 %1:sreg_32 = S_MOV_B32 %stack.0
62 %2:sreg_32 = S_ADD_I32 %0, %1, implicit-def $scc
64 SI_RETURN implicit $sgpr4
68 name: fold_frame_index__s_add_i32__fi_materializedconst_0
69 tracksRegLiveness: true
74 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
77 ; CHECK-LABEL: name: fold_frame_index__s_add_i32__fi_materializedconst_0
78 ; CHECK: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 256
79 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 %stack.0, [[S_MOV_B32_]], implicit-def $scc
80 ; CHECK-NEXT: $sgpr4 = COPY [[S_ADD_I32_]]
81 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
82 %0:sreg_32 = S_MOV_B32 %stack.0
83 %1:sreg_32 = S_MOV_B32 256
84 %2:sreg_32 = S_ADD_I32 %0, %1, implicit-def $scc
86 SI_RETURN implicit $sgpr4
91 name: fold_frame_index__s_add_i32__fi_materializedconst_1
92 tracksRegLiveness: true
97 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
100 ; CHECK-LABEL: name: fold_frame_index__s_add_i32__fi_materializedconst_1
101 ; CHECK: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 256, %stack.0, implicit-def $scc
102 ; CHECK-NEXT: $sgpr4 = COPY [[S_ADD_I32_]]
103 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
104 %0:sreg_32 = S_MOV_B32 256
105 %1:sreg_32 = S_MOV_B32 %stack.0
106 %2:sreg_32 = S_ADD_I32 %0, %1, implicit-def $scc
108 SI_RETURN implicit $sgpr4
112 name: fold_frame_index__s_add_i32__reg_fi
113 tracksRegLiveness: true
116 localFrameSize: 16384
118 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
122 ; CHECK-LABEL: name: fold_frame_index__s_add_i32__reg_fi
123 ; CHECK: liveins: $sgpr4
125 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr4
126 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[COPY]], %stack.0, implicit-def $scc
127 ; CHECK-NEXT: $sgpr4 = COPY [[S_ADD_I32_]]
128 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
129 %0:sreg_32 = COPY $sgpr4
130 %1:sreg_32 = S_MOV_B32 %stack.0
131 %2:sreg_32 = S_ADD_I32 %0, %1, implicit-def $scc
133 SI_RETURN implicit $sgpr4
137 name: fold_frame_index__s_add_i32__fi_reg
138 tracksRegLiveness: true
141 localFrameSize: 16384
143 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
147 ; CHECK-LABEL: name: fold_frame_index__s_add_i32__fi_reg
148 ; CHECK: liveins: $sgpr4
150 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr4
151 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 %stack.0, [[COPY]], implicit-def $scc
152 ; CHECK-NEXT: $sgpr4 = COPY [[S_ADD_I32_]]
153 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
154 %0:sreg_32 = COPY $sgpr4
155 %1:sreg_32 = S_MOV_B32 %stack.0
156 %2:sreg_32 = S_ADD_I32 %1, %0, implicit-def $scc
158 SI_RETURN implicit $sgpr4
162 name: fold_frame_index__v_add_u32_e32__const_v_fi
163 tracksRegLiveness: true
166 localFrameSize: 16384
168 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
171 ; CHECK-LABEL: name: fold_frame_index__v_add_u32_e32__const_v_fi
172 ; CHECK: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 128, %stack.0, implicit $exec
173 ; CHECK-NEXT: $sgpr4 = COPY [[V_ADD_U32_e32_]]
174 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
175 %0:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec
176 %1:vgpr_32 = V_ADD_U32_e32 128, %0, implicit $exec
178 SI_RETURN implicit $sgpr4
182 name: fold_frame_index__v_add_u32_e32__materialized_v_const_v_fi
183 tracksRegLiveness: true
186 localFrameSize: 16384
188 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
191 ; CHECK-LABEL: name: fold_frame_index__v_add_u32_e32__materialized_v_const_v_fi
192 ; CHECK: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 128, implicit $exec
193 ; CHECK-NEXT: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e32 %stack.0, [[V_MOV_B32_e32_]], implicit $exec
194 ; CHECK-NEXT: $sgpr4 = COPY [[V_ADD_U32_e32_]]
195 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
196 %0:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec
197 %1:vgpr_32 = V_MOV_B32_e32 128, implicit $exec
198 %2:vgpr_32 = V_ADD_U32_e32 %1, %0, implicit $exec
200 SI_RETURN implicit $sgpr4
204 name: fold_frame_index__v_add_u32_e64__imm_v_fi
205 tracksRegLiveness: true
208 localFrameSize: 16384
210 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
213 ; CHECK-LABEL: name: fold_frame_index__v_add_u32_e64__imm_v_fi
214 ; CHECK: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 64, %stack.0, 0, implicit $exec
215 ; CHECK-NEXT: $sgpr4 = COPY [[V_ADD_U32_e64_]]
216 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
217 %0:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec
218 %1:vgpr_32 = V_ADD_U32_e64 64, %0, 0, implicit $exec
220 SI_RETURN implicit $sgpr4
224 name: fold_frame_index__v_add_u32_e64___v_fi_imm
225 tracksRegLiveness: true
228 localFrameSize: 16384
230 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
233 ; CHECK-LABEL: name: fold_frame_index__v_add_u32_e64___v_fi_imm
234 ; CHECK: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 %stack.0, 64, 0, implicit $exec
235 ; CHECK-NEXT: $sgpr4 = COPY [[V_ADD_U32_e64_]]
236 ; CHECK-NEXT: SI_RETURN implicit $sgpr4
237 %0:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec
238 %1:vgpr_32 = V_ADD_U32_e64 %0, 64, 0, implicit $exec
240 SI_RETURN implicit $sgpr4
244 name: fold_frame_index__v_add_co_u32_e32__const_v_fi
245 tracksRegLiveness: true
248 localFrameSize: 16384
250 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
253 ; CHECK-LABEL: name: fold_frame_index__v_add_co_u32_e32__const_v_fi
254 ; CHECK: [[V_ADD_CO_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_CO_U32_e32 128, %stack.0, implicit-def $vcc, implicit $exec
255 ; CHECK-NEXT: $vgpr0 = COPY [[V_ADD_CO_U32_e32_]]
256 ; CHECK-NEXT: SI_RETURN implicit $vgpr0
257 %0:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec
258 %1:vgpr_32 = V_ADD_CO_U32_e32 128, %0, implicit-def $vcc, implicit $exec
260 SI_RETURN implicit $vgpr0
264 name: fold_frame_index__v_add_co_u32_e64__v_fi_imm
265 tracksRegLiveness: true
268 localFrameSize: 16384
270 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
273 ; CHECK-LABEL: name: fold_frame_index__v_add_co_u32_e64__v_fi_imm
274 ; CHECK: [[V_ADD_CO_U32_e64_:%[0-9]+]]:vgpr_32, [[V_ADD_CO_U32_e64_1:%[0-9]+]]:sreg_64 = V_ADD_CO_U32_e64 %stack.0, 64, 0, implicit $exec
275 ; CHECK-NEXT: $vgpr0 = COPY [[V_ADD_CO_U32_e64_]]
276 ; CHECK-NEXT: SI_RETURN implicit $vgpr0
277 %0:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec
278 %1:vgpr_32, %2:sreg_64 = V_ADD_CO_U32_e64 %0, 64, 0, implicit $exec
280 SI_RETURN implicit $vgpr0
284 name: fold_frame_index__v_add_co_u32_e64__imm_v_fi
285 tracksRegLiveness: true
288 localFrameSize: 16384
290 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
293 ; CHECK-LABEL: name: fold_frame_index__v_add_co_u32_e64__imm_v_fi
294 ; CHECK: [[V_ADD_CO_U32_e64_:%[0-9]+]]:vgpr_32, [[V_ADD_CO_U32_e64_1:%[0-9]+]]:sreg_64 = V_ADD_CO_U32_e64 64, %stack.0, 0, implicit $exec
295 ; CHECK-NEXT: $vgpr0 = COPY [[V_ADD_CO_U32_e64_]]
296 ; CHECK-NEXT: SI_RETURN implicit $vgpr0
297 %0:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec
298 %1:vgpr_32, %2:sreg_64 = V_ADD_CO_U32_e64 64, %0, 0, implicit $exec
300 SI_RETURN implicit $vgpr0
304 name: multi_use_scalar_fi__add_imm_add_inline_imm
305 tracksRegLiveness: true
308 localFrameSize: 16384
310 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
313 liveins: $sgpr0, $sgpr1
315 ; CHECK-LABEL: name: multi_use_scalar_fi__add_imm_add_inline_imm
316 ; CHECK: liveins: $sgpr0, $sgpr1
318 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
319 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
320 ; CHECK-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 %stack.0
321 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[S_MOV_B32_]], 16380, implicit-def dead $scc
322 ; CHECK-NEXT: [[S_ADD_I32_1:%[0-9]+]]:sreg_32 = S_ADD_I32 %stack.0, 56, implicit-def dead $scc
323 ; CHECK-NEXT: $sgpr4 = COPY [[S_ADD_I32_]]
324 ; CHECK-NEXT: $sgpr5 = COPY [[S_ADD_I32_1]]
325 ; CHECK-NEXT: SI_RETURN implicit $sgpr4, implicit $sgpr5
326 %0:sreg_32 = COPY $sgpr0
327 %1:sreg_32 = COPY $sgpr1
328 %2:sreg_32 = S_MOV_B32 16380
329 %3:sreg_32 = S_MOV_B32 56
330 %4:sreg_32 = S_MOV_B32 %stack.0
331 %5:sreg_32 = S_ADD_I32 %4, killed %2, implicit-def dead $scc
332 %6:sreg_32 = S_ADD_I32 %4, killed %3, implicit-def dead $scc
335 SI_RETURN implicit $sgpr4, implicit $sgpr5
339 name: multi_add_use_vector_fi__add_imm_add_inline_imm
340 tracksRegLiveness: true
343 localFrameSize: 16384
345 - { id: 0, size: 16384, alignment: 4, local-offset: 0 }
348 liveins: $vgpr0, $vgpr1
350 ; GFX9-LABEL: name: multi_add_use_vector_fi__add_imm_add_inline_imm
351 ; GFX9: liveins: $vgpr0, $vgpr1
353 ; GFX9-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
354 ; GFX9-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
355 ; GFX9-NEXT: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec
356 ; GFX9-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[V_MOV_B32_e32_]], killed [[COPY1]], 0, implicit $exec
357 ; GFX9-NEXT: [[V_ADD_U32_e64_1:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[V_MOV_B32_e32_]], 56, 0, implicit $exec
358 ; GFX9-NEXT: $vgpr0 = COPY [[V_ADD_U32_e64_]]
359 ; GFX9-NEXT: $vgpr1 = COPY [[V_ADD_U32_e64_1]]
360 ; GFX9-NEXT: SI_RETURN implicit $vgpr0, implicit $vgpr1
362 ; GFX10-LABEL: name: multi_add_use_vector_fi__add_imm_add_inline_imm
363 ; GFX10: liveins: $vgpr0, $vgpr1
365 ; GFX10-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
366 ; GFX10-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
367 ; GFX10-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 %stack.0, killed [[COPY1]], 0, implicit $exec
368 ; GFX10-NEXT: [[V_ADD_U32_e64_1:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 %stack.0, 56, 0, implicit $exec
369 ; GFX10-NEXT: $vgpr0 = COPY [[V_ADD_U32_e64_]]
370 ; GFX10-NEXT: $vgpr1 = COPY [[V_ADD_U32_e64_1]]
371 ; GFX10-NEXT: SI_RETURN implicit $vgpr0, implicit $vgpr1
373 ; GFX12-LABEL: name: multi_add_use_vector_fi__add_imm_add_inline_imm
374 ; GFX12: liveins: $vgpr0, $vgpr1
376 ; GFX12-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
377 ; GFX12-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
378 ; GFX12-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 %stack.0, killed [[COPY1]], 0, implicit $exec
379 ; GFX12-NEXT: [[V_ADD_U32_e64_1:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 %stack.0, 56, 0, implicit $exec
380 ; GFX12-NEXT: $vgpr0 = COPY [[V_ADD_U32_e64_]]
381 ; GFX12-NEXT: $vgpr1 = COPY [[V_ADD_U32_e64_1]]
382 ; GFX12-NEXT: SI_RETURN implicit $vgpr0, implicit $vgpr1
383 %0:vgpr_32 = COPY $vgpr0
384 %1:vgpr_32 = COPY $vgpr1
385 %2:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec
386 %3:vgpr_32 = V_ADD_U32_e64 %2, killed %1, 0, implicit $exec
387 %4:vgpr_32 = V_MOV_B32_e32 999, implicit $exec
389 %6:sreg_32 = S_MOV_B32 56
390 %7:vgpr_32 = V_ADD_U32_e64 %2, killed %6, 0, implicit $exec
394 SI_RETURN implicit $vgpr0, implicit $vgpr1