1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -O0 -run-pass=legalizer %s -o - | FileCheck %s
9 ; CHECK-LABEL: name: ctpop_s8_s8
10 ; CHECK: liveins: $vgpr0
12 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
13 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
14 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
15 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s32)
16 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY [[CTPOP]](s32)
17 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
18 ; CHECK-NEXT: $vgpr0 = COPY [[AND1]](s32)
19 %0:_(s32) = COPY $vgpr0
31 ; CHECK-LABEL: name: ctpop_s9_s9
32 ; CHECK: liveins: $vgpr0
34 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
35 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 511
36 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
37 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s32)
38 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY [[CTPOP]](s32)
39 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
40 ; CHECK-NEXT: $vgpr0 = COPY [[AND1]](s32)
41 %0:_(s32) = COPY $vgpr0
54 ; CHECK-LABEL: name: ctpop_s32_s32
55 ; CHECK: liveins: $vgpr0
57 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
58 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[COPY]](s32)
59 ; CHECK-NEXT: $vgpr0 = COPY [[CTPOP]](s32)
60 %0:_(s32) = COPY $vgpr0
61 %1:_(s32) = G_CTPOP %0
71 ; CHECK-LABEL: name: ctpop_s32_s64
72 ; CHECK: liveins: $vgpr0_vgpr1
74 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
75 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[COPY]](s64)
76 ; CHECK-NEXT: $vgpr0 = COPY [[CTPOP]](s32)
77 %0:_(s64) = COPY $vgpr0_vgpr1
78 %1:_(s32) = G_CTPOP %0
88 ; CHECK-LABEL: name: ctpop_s64_s64
89 ; CHECK: liveins: $vgpr0_vgpr1
91 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
92 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[COPY]](s64)
93 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[CTPOP]](s32)
94 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[ZEXT]](s64)
95 %0:_(s64) = COPY $vgpr0_vgpr1
96 %1:_(s64) = G_CTPOP %0
97 $vgpr0_vgpr1 = COPY %1
106 ; CHECK-LABEL: name: ctpop_s16_s32
107 ; CHECK: liveins: $vgpr0
109 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
110 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[COPY]](s32)
111 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
112 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[CTPOP]], [[C]]
113 ; CHECK-NEXT: $vgpr0 = COPY [[AND]](s32)
114 %0:_(s32) = COPY $vgpr0
115 %1:_(s16) = G_CTPOP %0
116 %2:_(s32) = G_ZEXT %1
126 ; CHECK-LABEL: name: ctpop_s16_s16
127 ; CHECK: liveins: $vgpr0
129 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
130 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
131 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
132 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s32)
133 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY [[CTPOP]](s32)
134 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
135 ; CHECK-NEXT: $vgpr0 = COPY [[AND1]](s32)
136 %0:_(s32) = COPY $vgpr0
137 %1:_(s16) = G_TRUNC %0
138 %2:_(s16) = G_CTPOP %1
139 %3:_(s32) = G_ZEXT %2
144 name: ctpop_v2s32_v2s32
148 liveins: $vgpr0_vgpr1
149 ; CHECK-LABEL: name: ctpop_v2s32_v2s32
150 ; CHECK: liveins: $vgpr0_vgpr1
152 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
153 ; CHECK-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
154 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[UV]](s32)
155 ; CHECK-NEXT: [[CTPOP1:%[0-9]+]]:_(s32) = G_CTPOP [[UV1]](s32)
156 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[CTPOP]](s32), [[CTPOP1]](s32)
157 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>)
158 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
159 %1:_(<2 x s32>) = G_CTPOP %0
160 $vgpr0_vgpr1 = COPY %1
164 name: ctpop_v2s32_v2s64
168 liveins: $vgpr0_vgpr1_vgpr2_vgpr3
169 ; CHECK-LABEL: name: ctpop_v2s32_v2s64
170 ; CHECK: liveins: $vgpr0_vgpr1_vgpr2_vgpr3
172 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
173 ; CHECK-NEXT: [[UV:%[0-9]+]]:_(s64), [[UV1:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[COPY]](<2 x s64>)
174 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[UV]](s64)
175 ; CHECK-NEXT: [[CTPOP1:%[0-9]+]]:_(s32) = G_CTPOP [[UV1]](s64)
176 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[CTPOP]](s32), [[CTPOP1]](s32)
177 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>)
178 %0:_(<2 x s64>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
179 %1:_(<2 x s32>) = G_CTPOP %0
180 $vgpr0_vgpr1 = COPY %1
184 name: ctpop_v2s16_v2s16
189 ; CHECK-LABEL: name: ctpop_v2s16_v2s16
190 ; CHECK: liveins: $vgpr0
192 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr0
193 ; CHECK-NEXT: [[BITCAST:%[0-9]+]]:_(s32) = G_BITCAST [[COPY]](<2 x s16>)
194 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
195 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BITCAST]], [[C]](s32)
196 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
197 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[BITCAST]], [[C1]]
198 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s32)
199 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY [[CTPOP]](s32)
200 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[LSHR]], [[C1]]
201 ; CHECK-NEXT: [[CTPOP1:%[0-9]+]]:_(s32) = G_CTPOP [[AND1]](s32)
202 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY [[CTPOP1]](s32)
203 ; CHECK-NEXT: [[AND2:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C1]]
204 ; CHECK-NEXT: [[AND3:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C1]]
205 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[AND3]], [[C]](s32)
206 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[AND2]], [[SHL]]
207 ; CHECK-NEXT: [[BITCAST1:%[0-9]+]]:_(<2 x s16>) = G_BITCAST [[OR]](s32)
208 ; CHECK-NEXT: $vgpr0 = COPY [[BITCAST1]](<2 x s16>)
209 %0:_(<2 x s16>) = COPY $vgpr0
210 %1:_(<2 x s16>) = G_CTPOP %0
221 ; CHECK-LABEL: name: ctpop_s7_s7
222 ; CHECK: liveins: $vgpr0
224 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
225 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 127
226 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
227 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s32)
228 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY [[CTPOP]](s32)
229 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
230 ; CHECK-NEXT: $vgpr0 = COPY [[AND1]](s32)
231 %0:_(s32) = COPY $vgpr0
232 %1:_(s7) = G_TRUNC %0
233 %2:_(s7) = G_CTPOP %1
234 %3:_(s32) = G_ZEXT %2
243 liveins: $vgpr0_vgpr1
245 ; CHECK-LABEL: name: ctpop_s33_s33
246 ; CHECK: liveins: $vgpr0_vgpr1
248 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
249 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8589934591
250 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
251 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s64)
252 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[CTPOP]](s32)
253 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[ZEXT]](s64)
254 %0:_(s64) = COPY $vgpr0_vgpr1
255 %1:_(s33) = G_TRUNC %0
256 %2:_(s33) = G_CTPOP %1
257 %3:_(s64) = G_ANYEXT %2
258 $vgpr0_vgpr1 = COPY %3
265 liveins: $vgpr0_vgpr1_vgpr2
266 ; CHECK-LABEL: name: ctpop_s65_s65
267 ; CHECK: liveins: $vgpr0_vgpr1_vgpr2
269 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s96) = COPY $vgpr0_vgpr1_vgpr2
270 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1
271 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
272 ; CHECK-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32), [[UV2:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](s96)
273 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
274 ; CHECK-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[UV]](s32), [[UV1]](s32)
275 ; CHECK-NEXT: [[MV1:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[UV2]](s32), [[DEF]](s32)
276 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[MV]], [[C]]
277 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[MV1]], [[C1]]
278 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s64)
279 ; CHECK-NEXT: [[CTPOP1:%[0-9]+]]:_(s32) = G_CTPOP [[AND1]](s64)
280 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[CTPOP1]], [[CTPOP]]
281 ; CHECK-NEXT: $vgpr0 = COPY [[ADD]](s32)
282 %0:_(s96) = COPY $vgpr0_vgpr1_vgpr2
283 %1:_(s65) = G_TRUNC %0
284 %2:_(s65) = G_CTPOP %1
285 %3:_(s32) = G_TRUNC %2
293 liveins: $vgpr0_vgpr1_vgpr2
294 ; CHECK-LABEL: name: ctpop_s32_s65
295 ; CHECK: liveins: $vgpr0_vgpr1_vgpr2
297 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s96) = COPY $vgpr0_vgpr1_vgpr2
298 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1
299 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
300 ; CHECK-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32), [[UV2:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](s96)
301 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
302 ; CHECK-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[UV]](s32), [[UV1]](s32)
303 ; CHECK-NEXT: [[MV1:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[UV2]](s32), [[DEF]](s32)
304 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[MV]], [[C]]
305 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[MV1]], [[C1]]
306 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s64)
307 ; CHECK-NEXT: [[CTPOP1:%[0-9]+]]:_(s32) = G_CTPOP [[AND1]](s64)
308 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[CTPOP1]], [[CTPOP]]
309 ; CHECK-NEXT: $vgpr0 = COPY [[ADD]](s32)
310 %0:_(s96) = COPY $vgpr0_vgpr1_vgpr2
311 %1:_(s65) = G_TRUNC %0
312 %2:_(s32) = G_CTPOP %1