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
3
4---
5name: ctpop_s32_s32
6
7body: |
8  bb.0:
9    liveins: $vgpr0
10    ; CHECK-LABEL: name: ctpop_s32_s32
11    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
12    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[COPY]](s32)
13    ; CHECK: $vgpr0 = COPY [[CTPOP]](s32)
14    %0:_(s32) = COPY $vgpr0
15    %1:_(s32) = G_CTPOP %0
16    $vgpr0 = COPY %1
17...
18
19---
20name: ctpop_s32_s64
21
22body: |
23  bb.0:
24    liveins: $vgpr0_vgpr1
25    ; CHECK-LABEL: name: ctpop_s32_s64
26    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
27    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[COPY]](s64)
28    ; CHECK: $vgpr0 = COPY [[CTPOP]](s32)
29    %0:_(s64) = COPY $vgpr0_vgpr1
30    %1:_(s32) = G_CTPOP %0
31    $vgpr0 = COPY %1
32...
33
34---
35name: ctpop_s64_s64
36
37body: |
38  bb.0:
39    liveins: $vgpr0_vgpr1
40    ; CHECK-LABEL: name: ctpop_s64_s64
41    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
42    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[COPY]](s64)
43    ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[CTPOP]](s32)
44    ; CHECK: $vgpr0_vgpr1 = COPY [[ZEXT]](s64)
45    %0:_(s64) = COPY $vgpr0_vgpr1
46    %1:_(s64) = G_CTPOP %0
47    $vgpr0_vgpr1 = COPY %1
48...
49
50---
51name: ctpop_s16_s32
52
53body: |
54  bb.0:
55    liveins: $vgpr0
56    ; CHECK-LABEL: name: ctpop_s16_s32
57    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
58    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[COPY]](s32)
59    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
60    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[CTPOP]], [[C]]
61    ; CHECK: $vgpr0 = COPY [[AND]](s32)
62    %0:_(s32) = COPY $vgpr0
63    %1:_(s16) = G_CTPOP %0
64    %2:_(s32) = G_ZEXT %1
65    $vgpr0 = COPY %2
66...
67
68---
69name: ctpop_s16_s16
70
71body: |
72  bb.0:
73    liveins: $vgpr0
74    ; CHECK-LABEL: name: ctpop_s16_s16
75    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
76    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
77    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
78    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s32)
79    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[CTPOP]](s32)
80    ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
81    ; CHECK: $vgpr0 = COPY [[AND1]](s32)
82    %0:_(s32) = COPY $vgpr0
83    %1:_(s16) = G_TRUNC %0
84    %2:_(s16) = G_CTPOP %1
85    %3:_(s32) = G_ZEXT %2
86    $vgpr0 = COPY %3
87...
88
89---
90name: ctpop_v2s32_v2s32
91
92body: |
93  bb.0:
94    liveins: $vgpr0_vgpr1
95    ; CHECK-LABEL: name: ctpop_v2s32_v2s32
96    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
97    ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
98    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[UV]](s32)
99    ; CHECK: [[CTPOP1:%[0-9]+]]:_(s32) = G_CTPOP [[UV1]](s32)
100    ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[CTPOP]](s32), [[CTPOP1]](s32)
101    ; CHECK: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>)
102    %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
103    %1:_(<2 x s32>) = G_CTPOP %0
104    $vgpr0_vgpr1 = COPY %1
105...
106
107---
108name: ctpop_v2s32_v2s64
109
110body: |
111  bb.0:
112    liveins: $vgpr0_vgpr1_vgpr2_vgpr3
113    ; CHECK-LABEL: name: ctpop_v2s32_v2s64
114    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
115    ; CHECK: [[UV:%[0-9]+]]:_(s64), [[UV1:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[COPY]](<2 x s64>)
116    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[UV]](s64)
117    ; CHECK: [[CTPOP1:%[0-9]+]]:_(s32) = G_CTPOP [[UV1]](s64)
118    ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[CTPOP]](s32), [[CTPOP1]](s32)
119    ; CHECK: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>)
120    %0:_(<2 x s64>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
121    %1:_(<2 x s32>) = G_CTPOP %0
122    $vgpr0_vgpr1 = COPY %1
123...
124
125---
126name: ctpop_v2s16_v2s16
127
128body: |
129  bb.0:
130    liveins: $vgpr0
131    ; CHECK-LABEL: name: ctpop_v2s16_v2s16
132    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr0
133    ; CHECK: [[BITCAST:%[0-9]+]]:_(s32) = G_BITCAST [[COPY]](<2 x s16>)
134    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
135    ; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BITCAST]], [[C]](s32)
136    ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
137    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[BITCAST]], [[C1]]
138    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s32)
139    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[CTPOP]](s32)
140    ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[LSHR]], [[C1]]
141    ; CHECK: [[CTPOP1:%[0-9]+]]:_(s32) = G_CTPOP [[AND1]](s32)
142    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[CTPOP1]](s32)
143    ; CHECK: [[AND2:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C1]]
144    ; CHECK: [[AND3:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C1]]
145    ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[AND3]], [[C]](s32)
146    ; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[AND2]], [[SHL]]
147    ; CHECK: [[BITCAST1:%[0-9]+]]:_(<2 x s16>) = G_BITCAST [[OR]](s32)
148    ; CHECK: $vgpr0 = COPY [[BITCAST1]](<2 x s16>)
149    %0:_(<2 x s16>) = COPY $vgpr0
150    %1:_(<2 x s16>) = G_CTPOP %0
151    $vgpr0 = COPY %1
152...
153
154---
155name: ctpop_s7_s7
156
157body: |
158  bb.0:
159    liveins: $vgpr0
160
161    ; CHECK-LABEL: name: ctpop_s7_s7
162    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
163    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 127
164    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
165    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s32)
166    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[CTPOP]](s32)
167    ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
168    ; CHECK: $vgpr0 = COPY [[AND1]](s32)
169    %0:_(s32) = COPY $vgpr0
170    %1:_(s7) = G_TRUNC %0
171    %2:_(s7) = G_CTPOP %1
172    %3:_(s32) = G_ZEXT %2
173    $vgpr0 = COPY %3
174...
175
176---
177name: ctpop_s33_s33
178
179body: |
180  bb.0:
181    liveins: $vgpr0_vgpr1
182
183    ; CHECK-LABEL: name: ctpop_s33_s33
184    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
185    ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8589934591
186    ; CHECK: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
187    ; CHECK: [[CTPOP:%[0-9]+]]:_(s32) = G_CTPOP [[AND]](s64)
188    ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[CTPOP]](s32)
189    ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4294967295
190    ; CHECK: [[AND1:%[0-9]+]]:_(s64) = G_AND [[ZEXT]], [[C1]]
191    ; CHECK: $vgpr0_vgpr1 = COPY [[AND1]](s64)
192    %0:_(s64) = COPY $vgpr0_vgpr1
193    %1:_(s33) = G_TRUNC %0
194    %2:_(s33) = G_CTPOP %1
195    %3:_(s64) = G_ANYEXT %2
196    $vgpr0_vgpr1 = COPY %3
197...
198