1 # RUN: llc -verify-machineinstrs -march=amdgcn -run-pass si-shrink-instructions -o - %s | FileCheck -check-prefix=GCN %s
2 # Check that add with carry out isn't incorrectly reduced to e32 when
3 # the carry out is a virtual register.
5 # TODO: We should run this test until the end of codegen to make sure
6 # that the post-RA run does manage to shrink it, but right now the
10 # GCN-LABEL: name: shrink_add_vop3{{$}}
11 # GCN: %29:vgpr_32, %9:sreg_64_xexec = V_ADD_I32_e64 %19, %17, 0, implicit $exec
12 # GCN: %24:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed %9, implicit $exec
15 exposesReturnsTwice: false
17 regBankSelected: false
19 tracksRegLiveness: true
21 - { id: 0, class: sgpr_64 }
22 - { id: 1, class: sreg_32_xm0 }
23 - { id: 2, class: sgpr_32 }
24 - { id: 3, class: vgpr_32 }
25 - { id: 4, class: sreg_64_xexec }
26 - { id: 5, class: sreg_64_xexec }
27 - { id: 6, class: sreg_32 }
28 - { id: 7, class: sreg_32 }
29 - { id: 8, class: sreg_32_xm0 }
30 - { id: 9, class: sreg_64_xexec }
31 - { id: 10, class: sreg_32_xm0 }
32 - { id: 11, class: sreg_32_xm0 }
33 - { id: 12, class: sgpr_64 }
34 - { id: 13, class: sgpr_128 }
35 - { id: 14, class: sreg_32_xm0 }
36 - { id: 15, class: sreg_64 }
37 - { id: 16, class: sgpr_128 }
38 - { id: 17, class: vgpr_32 }
39 - { id: 18, class: vreg_64 }
40 - { id: 19, class: vgpr_32 }
41 - { id: 20, class: vreg_64 }
42 - { id: 21, class: sreg_32_xm0 }
43 - { id: 22, class: sreg_32 }
44 - { id: 23, class: sreg_32 }
45 - { id: 24, class: vgpr_32 }
46 - { id: 25, class: vreg_64 }
47 - { id: 26, class: vgpr_32 }
48 - { id: 27, class: vreg_64 }
49 - { id: 28, class: vreg_64 }
50 - { id: 29, class: vgpr_32 }
52 - { reg: '$sgpr0_sgpr1', virtual-reg: '%0' }
53 - { reg: '$vgpr0', virtual-reg: '%3' }
55 isFrameAddressTaken: false
56 isReturnAddressTaken: false
65 hasOpaqueSPAdjustment: false
67 hasMustTailInVarArgFunc: false
70 liveins: $sgpr0_sgpr1, $vgpr0
73 %0 = COPY $sgpr0_sgpr1
74 %4 = S_LOAD_DWORDX2_IMM %0, 9, 0, 0
75 %5 = S_LOAD_DWORDX2_IMM %0, 11, 0, 0
76 %26 = V_ASHRREV_I32_e32 31, %3, implicit $exec
77 %27 = REG_SEQUENCE %3, 1, %26, 2
80 %12 = REG_SEQUENCE killed %11, 1, killed %10, 2
81 %13 = REG_SEQUENCE killed %5, 17, %12, 18
82 %28 = V_LSHL_B64 killed %27, 2, implicit $exec
83 %16 = REG_SEQUENCE killed %4, 17, %12, 18
84 %17 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 0, 0, 0, 0, 0, implicit $exec
85 %19 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 4, 0, 0, 0, 0, implicit $exec
86 %29, %9 = V_ADD_I32_e64 %19, %17, 0, implicit $exec
87 %24 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed %9, implicit $exec
88 BUFFER_STORE_DWORD_ADDR64 %24, %28, killed %16, 0, 0, 0, 0, 0, 0, implicit $exec
93 # GCN-LABEL: name: shrink_sub_vop3{{$}}
94 # GCN: %29:vgpr_32, %9:sreg_64_xexec = V_SUB_I32_e64 %19, %17, 0, implicit $exec
95 # GCN: %24:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed %9, implicit $exec
99 exposesReturnsTwice: false
101 regBankSelected: false
103 tracksRegLiveness: true
105 - { id: 0, class: sgpr_64 }
106 - { id: 1, class: sreg_32_xm0 }
107 - { id: 2, class: sgpr_32 }
108 - { id: 3, class: vgpr_32 }
109 - { id: 4, class: sreg_64_xexec }
110 - { id: 5, class: sreg_64_xexec }
111 - { id: 6, class: sreg_32 }
112 - { id: 7, class: sreg_32 }
113 - { id: 8, class: sreg_32_xm0 }
114 - { id: 9, class: sreg_64_xexec }
115 - { id: 10, class: sreg_32_xm0 }
116 - { id: 11, class: sreg_32_xm0 }
117 - { id: 12, class: sgpr_64 }
118 - { id: 13, class: sgpr_128 }
119 - { id: 14, class: sreg_32_xm0 }
120 - { id: 15, class: sreg_64 }
121 - { id: 16, class: sgpr_128 }
122 - { id: 17, class: vgpr_32 }
123 - { id: 18, class: vreg_64 }
124 - { id: 19, class: vgpr_32 }
125 - { id: 20, class: vreg_64 }
126 - { id: 21, class: sreg_32_xm0 }
127 - { id: 22, class: sreg_32 }
128 - { id: 23, class: sreg_32 }
129 - { id: 24, class: vgpr_32 }
130 - { id: 25, class: vreg_64 }
131 - { id: 26, class: vgpr_32 }
132 - { id: 27, class: vreg_64 }
133 - { id: 28, class: vreg_64 }
134 - { id: 29, class: vgpr_32 }
136 - { reg: '$sgpr0_sgpr1', virtual-reg: '%0' }
137 - { reg: '$vgpr0', virtual-reg: '%3' }
139 isFrameAddressTaken: false
140 isReturnAddressTaken: false
149 hasOpaqueSPAdjustment: false
151 hasMustTailInVarArgFunc: false
154 liveins: $sgpr0_sgpr1, $vgpr0
157 %0 = COPY $sgpr0_sgpr1
158 %4 = S_LOAD_DWORDX2_IMM %0, 9, 0, 0
159 %5 = S_LOAD_DWORDX2_IMM %0, 11, 0, 0
160 %26 = V_ASHRREV_I32_e32 31, %3, implicit $exec
161 %27 = REG_SEQUENCE %3, 1, %26, 2
162 %10 = S_MOV_B32 61440
164 %12 = REG_SEQUENCE killed %11, 1, killed %10, 2
165 %13 = REG_SEQUENCE killed %5, 17, %12, 18
166 %28 = V_LSHL_B64 killed %27, 2, implicit $exec
167 %16 = REG_SEQUENCE killed %4, 17, %12, 18
168 %17 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 0, 0, 0, 0, 0, implicit $exec
169 %19 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 4, 0, 0, 0, 0, implicit $exec
170 %29, %9 = V_SUB_I32_e64 %19, %17, 0, implicit $exec
171 %24 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed %9, implicit $exec
172 BUFFER_STORE_DWORD_ADDR64 %24, %28, killed %16, 0, 0, 0, 0, 0, 0, implicit $exec
177 # GCN-LABEL: name: shrink_subrev_vop3{{$}}
178 # GCN: %29:vgpr_32, %9:sreg_64_xexec = V_SUBREV_I32_e64 %19, %17, 0, implicit $exec
179 # GCN: %24:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed %9, implicit $exec
181 name: shrink_subrev_vop3
183 exposesReturnsTwice: false
185 regBankSelected: false
187 tracksRegLiveness: true
189 - { id: 0, class: sgpr_64 }
190 - { id: 1, class: sreg_32_xm0 }
191 - { id: 2, class: sgpr_32 }
192 - { id: 3, class: vgpr_32 }
193 - { id: 4, class: sreg_64_xexec }
194 - { id: 5, class: sreg_64_xexec }
195 - { id: 6, class: sreg_32 }
196 - { id: 7, class: sreg_32 }
197 - { id: 8, class: sreg_32_xm0 }
198 - { id: 9, class: sreg_64_xexec }
199 - { id: 10, class: sreg_32_xm0 }
200 - { id: 11, class: sreg_32_xm0 }
201 - { id: 12, class: sgpr_64 }
202 - { id: 13, class: sgpr_128 }
203 - { id: 14, class: sreg_32_xm0 }
204 - { id: 15, class: sreg_64 }
205 - { id: 16, class: sgpr_128 }
206 - { id: 17, class: vgpr_32 }
207 - { id: 18, class: vreg_64 }
208 - { id: 19, class: vgpr_32 }
209 - { id: 20, class: vreg_64 }
210 - { id: 21, class: sreg_32_xm0 }
211 - { id: 22, class: sreg_32 }
212 - { id: 23, class: sreg_32 }
213 - { id: 24, class: vgpr_32 }
214 - { id: 25, class: vreg_64 }
215 - { id: 26, class: vgpr_32 }
216 - { id: 27, class: vreg_64 }
217 - { id: 28, class: vreg_64 }
218 - { id: 29, class: vgpr_32 }
220 - { reg: '$sgpr0_sgpr1', virtual-reg: '%0' }
221 - { reg: '$vgpr0', virtual-reg: '%3' }
223 isFrameAddressTaken: false
224 isReturnAddressTaken: false
233 hasOpaqueSPAdjustment: false
235 hasMustTailInVarArgFunc: false
238 liveins: $sgpr0_sgpr1, $vgpr0
241 %0 = COPY $sgpr0_sgpr1
242 %4 = S_LOAD_DWORDX2_IMM %0, 9, 0, 0
243 %5 = S_LOAD_DWORDX2_IMM %0, 11, 0, 0
244 %26 = V_ASHRREV_I32_e32 31, %3, implicit $exec
245 %27 = REG_SEQUENCE %3, 1, %26, 2
246 %10 = S_MOV_B32 61440
248 %12 = REG_SEQUENCE killed %11, 1, killed %10, 2
249 %13 = REG_SEQUENCE killed %5, 17, %12, 18
250 %28 = V_LSHL_B64 killed %27, 2, implicit $exec
251 %16 = REG_SEQUENCE killed %4, 17, %12, 18
252 %17 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 0, 0, 0, 0, 0, implicit $exec
253 %19 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 4, 0, 0, 0, 0, implicit $exec
254 %29, %9 = V_SUBREV_I32_e64 %19, %17, 0, implicit $exec
255 %24 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed %9, implicit $exec
256 BUFFER_STORE_DWORD_ADDR64 %29, %28, killed %16, 0, 0, 0, 0, 0, 0, implicit $exec
261 # GCN-LABEL: name: check_addc_src2_vop3{{$}}
262 # GCN: %29:vgpr_32, $vcc = V_ADDC_U32_e64 %19, %17, %9, 0, implicit $exec
263 # GCN: %24:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed $vcc, implicit $exec
264 name: check_addc_src2_vop3
266 exposesReturnsTwice: false
268 regBankSelected: false
270 tracksRegLiveness: true
272 - { id: 0, class: sgpr_64 }
273 - { id: 1, class: sreg_32_xm0 }
274 - { id: 2, class: sgpr_32 }
275 - { id: 3, class: vgpr_32 }
276 - { id: 4, class: sreg_64_xexec }
277 - { id: 5, class: sreg_64_xexec }
278 - { id: 6, class: sreg_32 }
279 - { id: 7, class: sreg_32 }
280 - { id: 8, class: sreg_32_xm0 }
281 - { id: 9, class: sreg_64_xexec }
282 - { id: 10, class: sreg_32_xm0 }
283 - { id: 11, class: sreg_32_xm0 }
284 - { id: 12, class: sgpr_64 }
285 - { id: 13, class: sgpr_128 }
286 - { id: 14, class: sreg_32_xm0 }
287 - { id: 15, class: sreg_64 }
288 - { id: 16, class: sgpr_128 }
289 - { id: 17, class: vgpr_32 }
290 - { id: 18, class: vreg_64 }
291 - { id: 19, class: vgpr_32 }
292 - { id: 20, class: vreg_64 }
293 - { id: 21, class: sreg_32_xm0 }
294 - { id: 22, class: sreg_32 }
295 - { id: 23, class: sreg_32 }
296 - { id: 24, class: vgpr_32 }
297 - { id: 25, class: vreg_64 }
298 - { id: 26, class: vgpr_32 }
299 - { id: 27, class: vreg_64 }
300 - { id: 28, class: vreg_64 }
301 - { id: 29, class: vgpr_32 }
303 - { reg: '$sgpr0_sgpr1', virtual-reg: '%0' }
304 - { reg: '$vgpr0', virtual-reg: '%3' }
306 isFrameAddressTaken: false
307 isReturnAddressTaken: false
316 hasOpaqueSPAdjustment: false
318 hasMustTailInVarArgFunc: false
321 liveins: $sgpr0_sgpr1, $vgpr0
324 %0 = COPY $sgpr0_sgpr1
325 %4 = S_LOAD_DWORDX2_IMM %0, 9, 0, 0
326 %5 = S_LOAD_DWORDX2_IMM %0, 11, 0, 0
327 %26 = V_ASHRREV_I32_e32 31, %3, implicit $exec
328 %27 = REG_SEQUENCE %3, 1, %26, 2
329 %10 = S_MOV_B32 61440
331 %12 = REG_SEQUENCE killed %11, 1, killed %10, 2
332 %13 = REG_SEQUENCE killed %5, 17, %12, 18
333 %28 = V_LSHL_B64 killed %27, 2, implicit $exec
334 %16 = REG_SEQUENCE killed %4, 17, %12, 18
335 %17 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 0, 0, 0, 0, 0, implicit $exec
336 %19 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 4, 0, 0, 0, 0, implicit $exec
338 %29, $vcc = V_ADDC_U32_e64 %19, %17, %9, 0, implicit $exec
339 %24 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed $vcc, implicit $exec
340 BUFFER_STORE_DWORD_ADDR64 %24, %28, killed %16, 0, 0, 0, 0, 0, 0, implicit $exec
345 # GCN-LABEL: name: shrink_addc_vop3{{$}}
346 # GCN: %29:vgpr_32 = V_ADDC_U32_e32 %19, %17, implicit-def $vcc, implicit $vcc, implicit $exec
347 # GCN %24 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed $vcc, implicit $exec
349 name: shrink_addc_vop3
351 exposesReturnsTwice: false
353 regBankSelected: false
355 tracksRegLiveness: true
357 - { id: 0, class: sgpr_64 }
358 - { id: 1, class: sreg_32_xm0 }
359 - { id: 2, class: sgpr_32 }
360 - { id: 3, class: vgpr_32 }
361 - { id: 4, class: sreg_64_xexec }
362 - { id: 5, class: sreg_64_xexec }
363 - { id: 6, class: sreg_32 }
364 - { id: 7, class: sreg_32 }
365 - { id: 8, class: sreg_32_xm0 }
366 - { id: 9, class: sreg_64 }
367 - { id: 10, class: sreg_32_xm0 }
368 - { id: 11, class: sreg_32_xm0 }
369 - { id: 12, class: sgpr_64 }
370 - { id: 13, class: sgpr_128 }
371 - { id: 14, class: sreg_32_xm0 }
372 - { id: 15, class: sreg_64 }
373 - { id: 16, class: sgpr_128 }
374 - { id: 17, class: vgpr_32 }
375 - { id: 18, class: vreg_64 }
376 - { id: 19, class: vgpr_32 }
377 - { id: 20, class: vreg_64 }
378 - { id: 21, class: sreg_32_xm0 }
379 - { id: 22, class: sreg_32 }
380 - { id: 23, class: sreg_32 }
381 - { id: 24, class: vgpr_32 }
382 - { id: 25, class: vreg_64 }
383 - { id: 26, class: vgpr_32 }
384 - { id: 27, class: vreg_64 }
385 - { id: 28, class: vreg_64 }
386 - { id: 29, class: vgpr_32 }
388 - { reg: '$sgpr0_sgpr1', virtual-reg: '%0' }
389 - { reg: '$vgpr0', virtual-reg: '%3' }
391 isFrameAddressTaken: false
392 isReturnAddressTaken: false
401 hasOpaqueSPAdjustment: false
403 hasMustTailInVarArgFunc: false
406 liveins: $sgpr0_sgpr1, $vgpr0
409 %0 = COPY $sgpr0_sgpr1
410 %4 = S_LOAD_DWORDX2_IMM %0, 9, 0, 0
411 %5 = S_LOAD_DWORDX2_IMM %0, 11, 0, 0
412 %26 = V_ASHRREV_I32_e32 31, %3, implicit $exec
413 %27 = REG_SEQUENCE %3, 1, %26, 2
414 %10 = S_MOV_B32 61440
416 %12 = REG_SEQUENCE killed %11, 1, killed %10, 2
417 %13 = REG_SEQUENCE killed %5, 17, %12, 18
418 %28 = V_LSHL_B64 killed %27, 2, implicit $exec
419 %16 = REG_SEQUENCE killed %4, 17, %12, 18
420 %17 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 0, 0, 0, 0, 0, implicit $exec
421 %19 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 4, 0, 0, 0, 0, implicit $exec
423 %29, $vcc = V_ADDC_U32_e64 %19, %17, $vcc, 0, implicit $exec
424 %24 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed $vcc, implicit $exec
425 BUFFER_STORE_DWORD_ADDR64 %24, %28, killed %16, 0, 0, 0, 0, 0, 0, implicit $exec
431 # GCN-LABEL: name: shrink_addc_undef_vcc{{$}}
432 # GCN: %29:vgpr_32 = V_ADDC_U32_e32 %19, %17, implicit-def $vcc, implicit undef $vcc, implicit $exec
433 # GCN: %24:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed $vcc, implicit $exec
434 name: shrink_addc_undef_vcc
436 exposesReturnsTwice: false
438 regBankSelected: false
440 tracksRegLiveness: true
442 - { id: 0, class: sgpr_64 }
443 - { id: 1, class: sreg_32_xm0 }
444 - { id: 2, class: sgpr_32 }
445 - { id: 3, class: vgpr_32 }
446 - { id: 4, class: sreg_64_xexec }
447 - { id: 5, class: sreg_64_xexec }
448 - { id: 6, class: sreg_32 }
449 - { id: 7, class: sreg_32 }
450 - { id: 8, class: sreg_32_xm0 }
451 - { id: 9, class: sreg_64 }
452 - { id: 10, class: sreg_32_xm0 }
453 - { id: 11, class: sreg_32_xm0 }
454 - { id: 12, class: sgpr_64 }
455 - { id: 13, class: sgpr_128 }
456 - { id: 14, class: sreg_32_xm0 }
457 - { id: 15, class: sreg_64 }
458 - { id: 16, class: sgpr_128 }
459 - { id: 17, class: vgpr_32 }
460 - { id: 18, class: vreg_64 }
461 - { id: 19, class: vgpr_32 }
462 - { id: 20, class: vreg_64 }
463 - { id: 21, class: sreg_32_xm0 }
464 - { id: 22, class: sreg_32 }
465 - { id: 23, class: sreg_32 }
466 - { id: 24, class: vgpr_32 }
467 - { id: 25, class: vreg_64 }
468 - { id: 26, class: vgpr_32 }
469 - { id: 27, class: vreg_64 }
470 - { id: 28, class: vreg_64 }
471 - { id: 29, class: vgpr_32 }
473 - { reg: '$sgpr0_sgpr1', virtual-reg: '%0' }
474 - { reg: '$vgpr0', virtual-reg: '%3' }
476 isFrameAddressTaken: false
477 isReturnAddressTaken: false
486 hasOpaqueSPAdjustment: false
488 hasMustTailInVarArgFunc: false
491 liveins: $sgpr0_sgpr1, $vgpr0
494 %0 = COPY $sgpr0_sgpr1
495 %4 = S_LOAD_DWORDX2_IMM %0, 9, 0, 0
496 %5 = S_LOAD_DWORDX2_IMM %0, 11, 0, 0
497 %26 = V_ASHRREV_I32_e32 31, %3, implicit $exec
498 %27 = REG_SEQUENCE %3, 1, %26, 2
499 %10 = S_MOV_B32 61440
501 %12 = REG_SEQUENCE killed %11, 1, killed %10, 2
502 %13 = REG_SEQUENCE killed %5, 17, %12, 18
503 %28 = V_LSHL_B64 killed %27, 2, implicit $exec
504 %16 = REG_SEQUENCE killed %4, 17, %12, 18
505 %17 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 0, 0, 0, 0, 0, implicit $exec
506 %19 = BUFFER_LOAD_DWORD_ADDR64 %28, %13, 0, 4, 0, 0, 0, 0, implicit $exec
507 %29, $vcc = V_ADDC_U32_e64 %19, %17, undef $vcc, 0, implicit $exec
508 %24 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed $vcc, implicit $exec
509 BUFFER_STORE_DWORD_ADDR64 %24, %28, killed %16, 0, 0, 0, 0, 0, 0, implicit $exec