1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=amdgcn-amd-amdhsa -verify-machineinstrs -run-pass si-fold-operands,dead-mi-elimination  %s -o - | FileCheck -check-prefix=GCN %s
3
4---
5
6# Uses a carry out in an instruction that can't be shrunk.
7
8name: shrink_scalar_imm_vgpr_v_add_i32_e64_other_carry_out_use
9tracksRegLiveness: true
10
11body:             |
12  bb.0:
13    ; GCN-LABEL: name: shrink_scalar_imm_vgpr_v_add_i32_e64_other_carry_out_use
14    ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32_xm0 = S_MOV_B32 12345
15    ; GCN: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
16    ; GCN: [[V_ADD_CO_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_CO_U32_e32 [[S_MOV_B32_]], [[DEF]], implicit-def $vcc, implicit $exec
17    ; GCN: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY killed $vcc
18    ; GCN: S_ENDPGM 0, implicit [[COPY]]
19    %0:sreg_32_xm0 = S_MOV_B32 12345
20    %1:vgpr_32 = IMPLICIT_DEF
21    %2:vgpr_32 = IMPLICIT_DEF
22    %3:vgpr_32 = IMPLICIT_DEF
23
24    %4:vgpr_32, %5:sreg_64_xexec = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
25    S_ENDPGM 0, implicit %5
26
27...
28---
29
30name: shrink_scalar_imm_multi_use_with_used_carry
31tracksRegLiveness: true
32
33body:             |
34  bb.0:
35    ; GCN-LABEL: name: shrink_scalar_imm_multi_use_with_used_carry
36    ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32_xm0 = S_MOV_B32 12345
37    ; GCN: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
38    ; GCN: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
39    ; GCN: [[V_ADD_CO_U32_e64_:%[0-9]+]]:vgpr_32, [[V_ADD_CO_U32_e64_1:%[0-9]+]]:sreg_64_xexec = V_ADD_CO_U32_e64 [[S_MOV_B32_]], [[DEF]], 0, implicit $exec
40    ; GCN: [[V_ADD_CO_U32_e64_2:%[0-9]+]]:vgpr_32, [[V_ADD_CO_U32_e64_3:%[0-9]+]]:sreg_64_xexec = V_ADD_CO_U32_e64 [[S_MOV_B32_]], [[DEF1]], 0, implicit $exec
41    ; GCN: S_ENDPGM 0, implicit [[V_ADD_CO_U32_e64_1]], implicit [[V_ADD_CO_U32_e64_2]]
42    %0:sreg_32_xm0 = S_MOV_B32 12345
43    %1:vgpr_32 = IMPLICIT_DEF
44    %2:vgpr_32 = IMPLICIT_DEF
45    %3:vgpr_32 = IMPLICIT_DEF
46    %4:vgpr_32 = IMPLICIT_DEF
47
48    %5:vgpr_32, %6:sreg_64_xexec = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
49    %7:vgpr_32, %8:sreg_64_xexec = V_ADD_CO_U32_e64 %0, %2, 0, implicit $exec
50    S_ENDPGM 0, implicit %6, implicit %7
51
52...
53---
54
55# TODO: Is it OK to leave the broken use around on the DBG_VALUE?
56
57name: shrink_scalar_imm_vgpr_v_add_i32_e64_dbg_only_carry_out_use
58tracksRegLiveness: true
59
60body:             |
61  bb.0:
62    ; GCN-LABEL: name: shrink_scalar_imm_vgpr_v_add_i32_e64_dbg_only_carry_out_use
63    ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32_xm0 = S_MOV_B32 12345
64    ; GCN: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
65    ; GCN: [[V_ADD_CO_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_CO_U32_e32 [[S_MOV_B32_]], [[DEF]], implicit-def $vcc, implicit $exec
66    ; GCN: DBG_VALUE %5:sreg_64_xexec, $noreg
67    ; GCN: S_ENDPGM 0, implicit [[V_ADD_CO_U32_e32_]]
68    %0:sreg_32_xm0 = S_MOV_B32 12345
69    %1:vgpr_32 = IMPLICIT_DEF
70    %2:vgpr_32 = IMPLICIT_DEF
71    %3:vgpr_32 = IMPLICIT_DEF
72
73    %4:vgpr_32, %5:sreg_64_xexec = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
74    DBG_VALUE %5, $noreg
75    S_ENDPGM 0, implicit %4
76
77...
78
79---
80
81# Uses carry out in a normal pattern
82
83name: shrink_scalar_imm_vgpr_v_add_i32_e64_carry_out_use
84tracksRegLiveness: true
85
86body:             |
87  bb.0:
88    ; GCN-LABEL: name: shrink_scalar_imm_vgpr_v_add_i32_e64_carry_out_use
89    ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32_xm0 = S_MOV_B32 12345
90    ; GCN: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
91    ; GCN: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
92    ; GCN: [[DEF2:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
93    ; GCN: [[V_ADD_CO_U32_e32_:%[0-9]+]]:vgpr_32 = V_ADD_CO_U32_e32 [[S_MOV_B32_]], [[DEF]], implicit-def $vcc, implicit $exec
94    ; GCN: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY killed $vcc
95    ; GCN: [[V_ADDC_U32_e64_:%[0-9]+]]:vgpr_32, [[V_ADDC_U32_e64_1:%[0-9]+]]:sreg_64_xexec = V_ADDC_U32_e64 [[DEF1]], [[DEF2]], [[COPY]], 0, implicit $exec
96    ; GCN: S_ENDPGM 0, implicit [[V_ADDC_U32_e64_]]
97    %0:sreg_32_xm0 = S_MOV_B32 12345
98    %1:vgpr_32 = IMPLICIT_DEF
99    %2:vgpr_32 = IMPLICIT_DEF
100    %3:vgpr_32 = IMPLICIT_DEF
101
102    %4:vgpr_32, %5:sreg_64_xexec = V_ADD_CO_U32_e64 %0, %1, 0, implicit $exec
103    %6:vgpr_32, %7:sreg_64_xexec = V_ADDC_U32_e64 %2, %3, %5, 0, implicit $exec
104    S_ENDPGM 0, implicit %6
105
106...
107