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
16 ; CHECK: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
17 ; CHECK: [[S_BCNT1_I32_B32_:%[0-9]+]]:sreg_32 = S_BCNT1_I32_B32 [[COPY]], implicit-def $scc
18 ; CHECK: S_ENDPGM 0, implicit [[S_BCNT1_I32_B32_]]
19 %0:sgpr(s32) = COPY $sgpr0
20 %1:sgpr(s32) = G_CTPOP %0
21 S_ENDPGM 0, implicit %1
28 tracksRegLiveness: true
34 ; CHECK-LABEL: name: ctpop_s32_vs
35 ; CHECK: liveins: $sgpr0
36 ; CHECK: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
37 ; CHECK: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], 0, implicit $exec
38 ; CHECK: S_ENDPGM 0, implicit [[V_BCNT_U32_B32_e64_]]
39 %0:sgpr(s32) = COPY $sgpr0
40 %1:vgpr(s32) = G_CTPOP %0
41 S_ENDPGM 0, implicit %1
48 tracksRegLiveness: true
54 ; CHECK-LABEL: name: ctpop_s32_vv
55 ; CHECK: liveins: $vgpr0
56 ; CHECK: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
57 ; CHECK: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], 0, implicit $exec
58 ; CHECK: S_ENDPGM 0, implicit [[V_BCNT_U32_B32_e64_]]
59 %0:vgpr(s32) = COPY $vgpr0
60 %1:vgpr(s32) = G_CTPOP %0
61 S_ENDPGM 0, implicit %1
65 name: add_ctpop_s32_v_vv_commute0
68 tracksRegLiveness: true
72 liveins: $vgpr0, $vgpr1
74 ; CHECK-LABEL: name: add_ctpop_s32_v_vv_commute0
75 ; CHECK: liveins: $vgpr0, $vgpr1
76 ; CHECK: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
77 ; CHECK: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
78 ; CHECK: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], [[COPY1]], implicit $exec
79 ; CHECK: S_ENDPGM 0, implicit [[V_BCNT_U32_B32_e64_]]
80 %0:vgpr(s32) = COPY $vgpr0
81 %1:vgpr(s32) = COPY $vgpr1
82 %2:vgpr(s32) = G_CTPOP %0
83 %3:vgpr(s32) = G_ADD %2, %1
84 S_ENDPGM 0, implicit %3
88 name: add_ctpop_s32_v_vv_commute1
91 tracksRegLiveness: true
95 liveins: $vgpr0, $vgpr1
97 ; CHECK-LABEL: name: add_ctpop_s32_v_vv_commute1
98 ; CHECK: liveins: $vgpr0, $vgpr1
99 ; CHECK: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
100 ; CHECK: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
101 ; CHECK: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], [[COPY1]], implicit $exec
102 ; CHECK: S_ENDPGM 0, implicit [[V_BCNT_U32_B32_e64_]]
103 %0:vgpr(s32) = COPY $vgpr0
104 %1:vgpr(s32) = COPY $vgpr1
105 %2:vgpr(s32) = G_CTPOP %0
106 %3:vgpr(s32) = G_ADD %1, %2
107 S_ENDPGM 0, implicit %3
110 # Test add+ctpop pattern with all scalars. This should stay scalar.
112 name: add_ctpop_s32_s_ss_commute0
114 regBankSelected: true
115 tracksRegLiveness: true
119 liveins: $sgpr0, $sgpr1
121 ; CHECK-LABEL: name: add_ctpop_s32_s_ss_commute0
122 ; CHECK: liveins: $sgpr0, $sgpr1
123 ; CHECK: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
124 ; CHECK: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
125 ; CHECK: [[S_BCNT1_I32_B32_:%[0-9]+]]:sreg_32 = S_BCNT1_I32_B32 [[COPY]], implicit-def $scc
126 ; CHECK: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[S_BCNT1_I32_B32_]], [[COPY1]], implicit-def $scc
127 ; CHECK: S_ENDPGM 0, implicit [[S_ADD_I32_]]
128 %0:sgpr(s32) = COPY $sgpr0
129 %1:sgpr(s32) = COPY $sgpr1
130 %2:sgpr(s32) = G_CTPOP %0
131 %3:sgpr(s32) = G_ADD %2, %1
132 S_ENDPGM 0, implicit %3
136 name: add_ctpop_s32_v_vs_commute0
138 regBankSelected: true
139 tracksRegLiveness: true
143 liveins: $vgpr0, $sgpr0
145 ; CHECK-LABEL: name: add_ctpop_s32_v_vs_commute0
146 ; CHECK: liveins: $vgpr0, $sgpr0
147 ; CHECK: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
148 ; CHECK: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr0
149 ; CHECK: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], [[COPY1]], implicit $exec
150 ; CHECK: S_ENDPGM 0, implicit [[V_BCNT_U32_B32_e64_]]
151 %0:vgpr(s32) = COPY $vgpr0
152 %1:sgpr(s32) = COPY $sgpr0
153 %2:vgpr(s32) = G_CTPOP %0
154 %3:vgpr(s32) = G_ADD %2, %1
155 S_ENDPGM 0, implicit %3
158 # SGPR->VGPR ctpop with VALU add
160 name: add_ctpop_s32_v_sv_commute0
162 regBankSelected: true
163 tracksRegLiveness: true
167 liveins: $vgpr0, $sgpr0
169 ; CHECK-LABEL: name: add_ctpop_s32_v_sv_commute0
170 ; CHECK: liveins: $vgpr0, $sgpr0
171 ; CHECK: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
172 ; CHECK: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr0
173 ; CHECK: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY1]], [[COPY]], implicit $exec
174 ; CHECK: S_ENDPGM 0, implicit [[V_BCNT_U32_B32_e64_]]
175 %0:vgpr(s32) = COPY $vgpr0
176 %1:sgpr(s32) = COPY $sgpr0
177 %2:vgpr(s32) = G_CTPOP %1
178 %3:vgpr(s32) = G_ADD %2, %0
179 S_ENDPGM 0, implicit %3
182 # Scalar ctpop with VALU add
184 name: add_ctpop_s32_s_sv_commute0
186 regBankSelected: true
187 tracksRegLiveness: true
191 liveins: $sgpr0, $vgpr0
193 ; CHECK-LABEL: name: add_ctpop_s32_s_sv_commute0
194 ; CHECK: liveins: $sgpr0, $vgpr0
195 ; CHECK: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
196 ; CHECK: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr0
197 ; CHECK: [[V_BCNT_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_BCNT_U32_B32_e64 [[COPY]], [[COPY1]], implicit $exec
198 ; CHECK: S_ENDPGM 0, implicit [[V_BCNT_U32_B32_e64_]]
199 %0:sgpr(s32) = COPY $sgpr0
200 %1:vgpr(s32) = COPY $vgpr0
201 %2:sgpr(s32) = G_CTPOP %0
202 %3:vgpr(s32) = G_ADD %2, %1
203 S_ENDPGM 0, implicit %3
209 regBankSelected: true
210 tracksRegLiveness: true
214 liveins: $sgpr0_sgpr1
216 ; CHECK-LABEL: name: ctpop_s64_ss
217 ; CHECK: liveins: $sgpr0_sgpr1
218 ; CHECK: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
219 ; CHECK: [[S_BCNT1_I32_B64_:%[0-9]+]]:sreg_32 = S_BCNT1_I32_B64 [[COPY]], implicit-def $scc
220 ; CHECK: S_ENDPGM 0, implicit [[S_BCNT1_I32_B64_]]
221 %0:sgpr(s64) = COPY $sgpr0_sgpr1
222 %1:sgpr(s32) = G_CTPOP %0
223 S_ENDPGM 0, implicit %1