1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -mcpu=tahiti -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
8 tracksRegLiveness: true
14 ; CHECK-LABEL: name: ctpop_s32_ss
15 ; CHECK: liveins: $sgpr0
17 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
18 ; CHECK-NEXT: [[S_BCNT1_I32_B32_:%[0-9]+]]:sreg_32 = S_BCNT1_I32_B32 [[COPY]], implicit-def dead $scc
19 ; CHECK-NEXT: S_ENDPGM 0, implicit [[S_BCNT1_I32_B32_]]
20 %0:sgpr(s32) = COPY $sgpr0
21 %1:sgpr(s32) = G_CTPOP %0
22 S_ENDPGM 0, implicit %1
29 tracksRegLiveness: true
35 ; CHECK-LABEL: name: ctpop_s32_vs
36 ; CHECK: liveins: $sgpr0
38 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
39 ; CHECK-NEXT: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], 0, implicit $exec
40 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_BCNT_U32_B32_e64_]]
41 %0:sgpr(s32) = COPY $sgpr0
42 %1:vgpr(s32) = G_CTPOP %0
43 S_ENDPGM 0, implicit %1
50 tracksRegLiveness: true
56 ; CHECK-LABEL: name: ctpop_s32_vv
57 ; CHECK: liveins: $vgpr0
59 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
60 ; CHECK-NEXT: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], 0, implicit $exec
61 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_BCNT_U32_B32_e64_]]
62 %0:vgpr(s32) = COPY $vgpr0
63 %1:vgpr(s32) = G_CTPOP %0
64 S_ENDPGM 0, implicit %1
68 name: add_ctpop_s32_v_vv_commute0
71 tracksRegLiveness: true
75 liveins: $vgpr0, $vgpr1
77 ; CHECK-LABEL: name: add_ctpop_s32_v_vv_commute0
78 ; CHECK: liveins: $vgpr0, $vgpr1
80 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
81 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
82 ; CHECK-NEXT: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], 0, implicit $exec
83 ; CHECK-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 [[V_BCNT_U32_B32_e64_]], [[COPY1]], 0, implicit $exec
84 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_ADD_CO_U32_e64_]]
85 %0:vgpr(s32) = COPY $vgpr0
86 %1:vgpr(s32) = COPY $vgpr1
87 %2:vgpr(s32) = G_CTPOP %0
88 %3:vgpr(s32) = G_ADD %2, %1
89 S_ENDPGM 0, implicit %3
93 name: add_ctpop_s32_v_vv_commute1
96 tracksRegLiveness: true
100 liveins: $vgpr0, $vgpr1
102 ; CHECK-LABEL: name: add_ctpop_s32_v_vv_commute1
103 ; CHECK: liveins: $vgpr0, $vgpr1
105 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
106 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
107 ; CHECK-NEXT: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], 0, implicit $exec
108 ; CHECK-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 [[COPY1]], [[V_BCNT_U32_B32_e64_]], 0, implicit $exec
109 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_ADD_CO_U32_e64_]]
110 %0:vgpr(s32) = COPY $vgpr0
111 %1:vgpr(s32) = COPY $vgpr1
112 %2:vgpr(s32) = G_CTPOP %0
113 %3:vgpr(s32) = G_ADD %1, %2
114 S_ENDPGM 0, implicit %3
117 # Test add+ctpop pattern with all scalars. This should stay scalar.
119 name: add_ctpop_s32_s_ss_commute0
121 regBankSelected: true
122 tracksRegLiveness: true
126 liveins: $sgpr0, $sgpr1
128 ; CHECK-LABEL: name: add_ctpop_s32_s_ss_commute0
129 ; CHECK: liveins: $sgpr0, $sgpr1
131 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
132 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
133 ; CHECK-NEXT: [[S_BCNT1_I32_B32_:%[0-9]+]]:sreg_32 = S_BCNT1_I32_B32 [[COPY]], implicit-def dead $scc
134 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[S_BCNT1_I32_B32_]], [[COPY1]], implicit-def dead $scc
135 ; CHECK-NEXT: S_ENDPGM 0, implicit [[S_ADD_I32_]]
136 %0:sgpr(s32) = COPY $sgpr0
137 %1:sgpr(s32) = COPY $sgpr1
138 %2:sgpr(s32) = G_CTPOP %0
139 %3:sgpr(s32) = G_ADD %2, %1
140 S_ENDPGM 0, implicit %3
144 name: add_ctpop_s32_v_vs_commute0
146 regBankSelected: true
147 tracksRegLiveness: true
151 liveins: $vgpr0, $sgpr0
153 ; CHECK-LABEL: name: add_ctpop_s32_v_vs_commute0
154 ; CHECK: liveins: $vgpr0, $sgpr0
156 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
157 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr0
158 ; CHECK-NEXT: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], 0, implicit $exec
159 ; CHECK-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 [[V_BCNT_U32_B32_e64_]], [[COPY1]], 0, implicit $exec
160 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_ADD_CO_U32_e64_]]
161 %0:vgpr(s32) = COPY $vgpr0
162 %1:sgpr(s32) = COPY $sgpr0
163 %2:vgpr(s32) = G_CTPOP %0
164 %3:vgpr(s32) = G_ADD %2, %1
165 S_ENDPGM 0, implicit %3
168 # SGPR->VGPR ctpop with VALU add
170 name: add_ctpop_s32_v_sv_commute0
172 regBankSelected: true
173 tracksRegLiveness: true
177 liveins: $vgpr0, $sgpr0
179 ; CHECK-LABEL: name: add_ctpop_s32_v_sv_commute0
180 ; CHECK: liveins: $vgpr0, $sgpr0
182 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
183 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr0
184 ; CHECK-NEXT: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY1]], 0, implicit $exec
185 ; CHECK-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 [[V_BCNT_U32_B32_e64_]], [[COPY]], 0, implicit $exec
186 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_ADD_CO_U32_e64_]]
187 %0:vgpr(s32) = COPY $vgpr0
188 %1:sgpr(s32) = COPY $sgpr0
189 %2:vgpr(s32) = G_CTPOP %1
190 %3:vgpr(s32) = G_ADD %2, %0
191 S_ENDPGM 0, implicit %3
194 # Scalar ctpop with VALU add
196 name: add_ctpop_s32_s_sv_commute0
198 regBankSelected: true
199 tracksRegLiveness: true
203 liveins: $sgpr0, $vgpr0
205 ; CHECK-LABEL: name: add_ctpop_s32_s_sv_commute0
206 ; CHECK: liveins: $sgpr0, $vgpr0
208 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
209 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr0
210 ; CHECK-NEXT: [[S_BCNT1_I32_B32_:%[0-9]+]]:sreg_32 = S_BCNT1_I32_B32 [[COPY]], implicit-def dead $scc
211 ; CHECK-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 [[S_BCNT1_I32_B32_]], [[COPY1]], 0, implicit $exec
212 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_ADD_CO_U32_e64_]]
213 %0:sgpr(s32) = COPY $sgpr0
214 %1:vgpr(s32) = COPY $vgpr0
215 %2:sgpr(s32) = G_CTPOP %0
216 %3:vgpr(s32) = G_ADD %2, %1
217 S_ENDPGM 0, implicit %3
223 regBankSelected: true
224 tracksRegLiveness: true
228 liveins: $sgpr0_sgpr1
230 ; CHECK-LABEL: name: ctpop_s64_ss
231 ; CHECK: liveins: $sgpr0_sgpr1
233 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
234 ; CHECK-NEXT: [[S_BCNT1_I32_B64_:%[0-9]+]]:sreg_32 = S_BCNT1_I32_B64 [[COPY]], implicit-def dead $scc
235 ; CHECK-NEXT: S_ENDPGM 0, implicit [[S_BCNT1_I32_B64_]]
236 %0:sgpr(s64) = COPY $sgpr0_sgpr1
237 %1:sgpr(s32) = G_CTPOP %0
238 S_ENDPGM 0, implicit %1