1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn -mcpu=fiji -run-pass=amdgpu-regbankselect -regbankselect-fast -verify-machineinstrs -o - %s | FileCheck %s
3 # RUN: llc -mtriple=amdgcn -mcpu=fiji -run-pass=amdgpu-regbankselect -regbankselect-greedy -verify-machineinstrs -o - %s | FileCheck %s
7 # Generate the 3 operand vector bitfield extract instructions for 32-bit
10 name: test_sbfx_s32_vvv
15 liveins: $vgpr0, $vgpr1, $vgpr2
17 ; CHECK-LABEL: name: test_sbfx_s32_vvv
18 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2
20 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
21 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY $vgpr1
22 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY $vgpr2
23 ; CHECK-NEXT: [[SBFX:%[0-9]+]]:vgpr(s32) = G_SBFX [[COPY]], [[COPY1]](s32), [[COPY2]]
24 ; CHECK-NEXT: $vgpr0 = COPY [[SBFX]](s32)
25 %0:_(s32) = COPY $vgpr0
26 %1:_(s32) = COPY $vgpr1
27 %2:_(s32) = COPY $vgpr2
28 %3:_(s32) = G_SBFX %0, %1(s32), %2
33 name: test_sbfx_s32_vii
40 ; CHECK-LABEL: name: test_sbfx_s32_vii
41 ; CHECK: liveins: $vgpr0
43 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
44 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 10
45 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 4
46 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32)
47 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[C1]](s32)
48 ; CHECK-NEXT: [[SBFX:%[0-9]+]]:vgpr(s32) = G_SBFX [[COPY]], [[COPY1]](s32), [[COPY2]]
49 ; CHECK-NEXT: $vgpr0 = COPY [[SBFX]](s32)
50 %0:_(s32) = COPY $vgpr0
51 %1:_(s32) = G_CONSTANT i32 10
52 %2:_(s32) = G_CONSTANT i32 4
53 %3:_(s32) = G_SBFX %0, %1(s32), %2
58 name: test_sbfx_s32_vss
63 liveins: $vgpr0, $sgpr0, $sgpr1
65 ; CHECK-LABEL: name: test_sbfx_s32_vss
66 ; CHECK: liveins: $vgpr0, $sgpr0, $sgpr1
68 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
69 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
70 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
71 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[COPY1]](s32)
72 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:vgpr(s32) = COPY [[COPY2]](s32)
73 ; CHECK-NEXT: [[SBFX:%[0-9]+]]:vgpr(s32) = G_SBFX [[COPY]], [[COPY3]](s32), [[COPY4]]
74 ; CHECK-NEXT: $vgpr0 = COPY [[SBFX]](s32)
75 %0:_(s32) = COPY $vgpr0
76 %1:_(s32) = COPY $sgpr0
77 %2:_(s32) = COPY $sgpr1
78 %3:_(s32) = G_SBFX %0, %1(s32), %2
82 # Expand to a sequence that implements the 64-bit bitfield extract using
85 name: test_sbfx_s64_vvv
90 liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3
92 ; CHECK-LABEL: name: test_sbfx_s64_vvv
93 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3
95 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s64) = COPY $vgpr0_vgpr1
96 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY $vgpr2
97 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY $vgpr3
98 ; CHECK-NEXT: [[ASHR:%[0-9]+]]:vgpr(s64) = G_ASHR [[COPY]], [[COPY1]](s32)
99 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[ASHR]](s64)
100 ; CHECK-NEXT: [[C:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 64
101 ; CHECK-NEXT: [[SUB:%[0-9]+]]:vgpr(s32) = G_SUB [[C]], [[COPY2]]
102 ; CHECK-NEXT: [[SHL:%[0-9]+]]:vgpr(s64) = G_SHL [[ASHR]], [[SUB]](s32)
103 ; CHECK-NEXT: [[ASHR1:%[0-9]+]]:vgpr(s64) = G_ASHR [[SHL]], [[SUB]](s32)
104 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY %3:vgpr(s64)
105 %0:_(s64) = COPY $vgpr0_vgpr1
106 %1:_(s32) = COPY $vgpr2
107 %2:_(s32) = COPY $vgpr3
108 %3:_(s64) = G_SBFX %0, %1(s32), %2
109 $vgpr0_vgpr1 = COPY %3(s64)
113 name: test_sbfx_s64_vss
118 liveins: $vgpr0_vgpr1, $sgpr0, $sgpr1
120 ; CHECK-LABEL: name: test_sbfx_s64_vss
121 ; CHECK: liveins: $vgpr0_vgpr1, $sgpr0, $sgpr1
123 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s64) = COPY $vgpr0_vgpr1
124 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
125 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY $vgpr1
126 ; CHECK-NEXT: [[ASHR:%[0-9]+]]:vgpr(s64) = G_ASHR [[COPY]], [[COPY1]](s32)
127 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[ASHR]](s64)
128 ; CHECK-NEXT: [[C:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 64
129 ; CHECK-NEXT: [[SUB:%[0-9]+]]:vgpr(s32) = G_SUB [[C]], [[COPY2]]
130 ; CHECK-NEXT: [[SHL:%[0-9]+]]:vgpr(s64) = G_SHL [[ASHR]], [[SUB]](s32)
131 ; CHECK-NEXT: [[ASHR1:%[0-9]+]]:vgpr(s64) = G_ASHR [[SHL]], [[SUB]](s32)
132 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY %3:vgpr(s64)
133 %0:_(s64) = COPY $vgpr0_vgpr1
134 %1:_(s32) = COPY $vgpr0
135 %2:_(s32) = COPY $vgpr1
136 %3:_(s64) = G_SBFX %0, %1(s32), %2
137 $vgpr0_vgpr1 = COPY %3(s64)
140 # If the offset and width are constants, use the 32-bit bitfield extract,
141 # and merge to create a 64-bit result.
143 name: test_sbfx_s64_vii_small
148 liveins: $vgpr0_vgpr1
150 ; CHECK-LABEL: name: test_sbfx_s64_vii_small
151 ; CHECK: liveins: $vgpr0_vgpr1
153 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s64) = COPY $vgpr0_vgpr1
154 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 31
155 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 4
156 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32)
157 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[C1]](s32)
158 ; CHECK-NEXT: [[ASHR:%[0-9]+]]:vgpr(s64) = G_ASHR [[COPY]], [[COPY1]](s32)
159 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[ASHR]](s64)
160 ; CHECK-NEXT: [[C2:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 0
161 ; CHECK-NEXT: [[SBFX:%[0-9]+]]:vgpr(s32) = G_SBFX [[UV]], [[C2]](s32), [[COPY2]]
162 ; CHECK-NEXT: [[C3:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 31
163 ; CHECK-NEXT: [[ASHR1:%[0-9]+]]:vgpr(s32) = G_ASHR [[SBFX]], [[C3]](s32)
164 ; CHECK-NEXT: [[MV:%[0-9]+]]:vgpr(s64) = G_MERGE_VALUES [[SBFX]](s32), [[ASHR1]](s32)
165 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[MV]](s64)
166 %0:_(s64) = COPY $vgpr0_vgpr1
167 %1:_(s32) = G_CONSTANT i32 31
168 %2:_(s32) = G_CONSTANT i32 4
169 %3:_(s64) = G_SBFX %0, %1(s32), %2
170 $vgpr0_vgpr1 = COPY %3(s64)
174 name: test_sbfx_s64_vii_big
179 liveins: $vgpr0_vgpr1
181 ; CHECK-LABEL: name: test_sbfx_s64_vii_big
182 ; CHECK: liveins: $vgpr0_vgpr1
184 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s64) = COPY $vgpr0_vgpr1
185 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 8
186 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 40
187 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32)
188 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[C1]](s32)
189 ; CHECK-NEXT: [[ASHR:%[0-9]+]]:vgpr(s64) = G_ASHR [[COPY]], [[COPY1]](s32)
190 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[ASHR]](s64)
191 ; CHECK-NEXT: [[C2:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 0
192 ; CHECK-NEXT: [[C3:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 8
193 ; CHECK-NEXT: [[SBFX:%[0-9]+]]:vgpr(s32) = G_SBFX [[UV1]], [[C2]](s32), [[C3]]
194 ; CHECK-NEXT: [[MV:%[0-9]+]]:vgpr(s64) = G_MERGE_VALUES [[UV]](s32), [[SBFX]](s32)
195 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[MV]](s64)
196 %0:_(s64) = COPY $vgpr0_vgpr1
197 %1:_(s32) = G_CONSTANT i32 8
198 %2:_(s32) = G_CONSTANT i32 40
199 %3:_(s64) = G_SBFX %0, %1(s32), %2
200 $vgpr0_vgpr1 = COPY %3(s64)
204 name: test_sbfx_s64_svv
209 liveins: $sgpr0_sgpr1, $vgpr0, $vgpr1
211 ; CHECK-LABEL: name: test_sbfx_s64_svv
212 ; CHECK: liveins: $sgpr0_sgpr1, $vgpr0, $vgpr1
214 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sgpr(s64) = COPY $sgpr0_sgpr1
215 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
216 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY $vgpr1
217 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vgpr(s64) = COPY [[COPY]](s64)
218 ; CHECK-NEXT: [[ASHR:%[0-9]+]]:vgpr(s64) = G_ASHR [[COPY3]], [[COPY1]](s32)
219 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[ASHR]](s64)
220 ; CHECK-NEXT: [[C:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 64
221 ; CHECK-NEXT: [[SUB:%[0-9]+]]:vgpr(s32) = G_SUB [[C]], [[COPY2]]
222 ; CHECK-NEXT: [[SHL:%[0-9]+]]:vgpr(s64) = G_SHL [[ASHR]], [[SUB]](s32)
223 ; CHECK-NEXT: [[ASHR1:%[0-9]+]]:vgpr(s64) = G_ASHR [[SHL]], [[SUB]](s32)
224 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY %3:vgpr(s64)
225 %0:_(s64) = COPY $sgpr0_sgpr1
226 %1:_(s32) = COPY $vgpr0
227 %2:_(s32) = COPY $vgpr1
228 %3:_(s64) = G_SBFX %0, %1(s32), %2
229 $vgpr0_vgpr1 = COPY %3(s64)
232 # Expand to a sequence that combines the offset and width for the two operand
233 # version of the 32-bit instruction.
235 name: test_sbfx_s32_svv
240 liveins: $sgpr0, $vgpr0, $vgpr1
242 ; CHECK-LABEL: name: test_sbfx_s32_svv
243 ; CHECK: liveins: $sgpr0, $vgpr0, $vgpr1
245 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
246 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
247 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY $vgpr1
248 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[COPY]](s32)
249 ; CHECK-NEXT: [[SBFX:%[0-9]+]]:vgpr(s32) = G_SBFX [[COPY3]], [[COPY1]](s32), [[COPY2]]
250 ; CHECK-NEXT: $vgpr0 = COPY [[SBFX]](s32)
251 %0:_(s32) = COPY $sgpr0
252 %1:_(s32) = COPY $vgpr0
253 %2:_(s32) = COPY $vgpr1
254 %3:_(s32) = G_SBFX %0, %1(s32), %2
255 $vgpr0 = COPY %3(s32)
259 name: test_sbfx_s32_sss
264 liveins: $sgpr0, $sgpr1, $sgpr3
266 ; CHECK-LABEL: name: test_sbfx_s32_sss
267 ; CHECK: liveins: $sgpr0, $sgpr1, $sgpr3
269 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32(s32) = COPY $sgpr0
270 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
271 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr2
272 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 63
273 ; CHECK-NEXT: [[AND:%[0-9]+]]:sgpr(s32) = G_AND [[COPY1]], [[C]]
274 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 16
275 ; CHECK-NEXT: [[SHL:%[0-9]+]]:sgpr(s32) = G_SHL [[COPY2]], [[C1]](s32)
276 ; CHECK-NEXT: [[OR:%[0-9]+]]:sreg_32(s32) = G_OR [[AND]], [[SHL]]
277 ; CHECK-NEXT: [[S_BFE_I32_:%[0-9]+]]:sreg_32(s32) = S_BFE_I32 [[COPY]](s32), [[OR]](s32), implicit-def $scc
278 ; CHECK-NEXT: $sgpr0 = COPY [[S_BFE_I32_]](s32)
279 %0:_(s32) = COPY $sgpr0
280 %1:_(s32) = COPY $sgpr1
281 %2:_(s32) = COPY $sgpr2
282 %3:_(s32) = G_SBFX %0, %1(s32), %2
283 $sgpr0 = COPY %3(s32)
287 name: test_sbfx_s32_sii
294 ; CHECK-LABEL: name: test_sbfx_s32_sii
295 ; CHECK: liveins: $sgpr0
297 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32(s32) = COPY $sgpr0
298 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 1
299 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 10
300 ; CHECK-NEXT: [[C2:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 63
301 ; CHECK-NEXT: [[AND:%[0-9]+]]:sgpr(s32) = G_AND [[C]], [[C2]]
302 ; CHECK-NEXT: [[C3:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 16
303 ; CHECK-NEXT: [[SHL:%[0-9]+]]:sgpr(s32) = G_SHL [[C1]], [[C3]](s32)
304 ; CHECK-NEXT: [[OR:%[0-9]+]]:sreg_32(s32) = G_OR [[AND]], [[SHL]]
305 ; CHECK-NEXT: [[S_BFE_I32_:%[0-9]+]]:sreg_32(s32) = S_BFE_I32 [[COPY]](s32), [[OR]](s32), implicit-def $scc
306 ; CHECK-NEXT: $sgpr0 = COPY [[S_BFE_I32_]](s32)
307 %0:_(s32) = COPY $sgpr0
308 %1:_(s32) = G_CONSTANT i32 1
309 %2:_(s32) = G_CONSTANT i32 10
310 %3:_(s32) = G_SBFX %0, %1(s32), %2
311 $sgpr0 = COPY %3(s32)
314 # Expand to a sequence that combines the offset and width for the two operand
315 # version of the 64-bit scalar instruction.
317 name: test_sbfx_s64_sss
322 liveins: $sgpr0_sgpr1, $sgpr0, $sgpr1
324 ; CHECK-LABEL: name: test_sbfx_s64_sss
325 ; CHECK: liveins: $sgpr0_sgpr1, $sgpr0, $sgpr1
327 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64(s64) = COPY $sgpr0_sgpr1
328 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
329 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
330 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 63
331 ; CHECK-NEXT: [[AND:%[0-9]+]]:sgpr(s32) = G_AND [[COPY1]], [[C]]
332 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 16
333 ; CHECK-NEXT: [[SHL:%[0-9]+]]:sgpr(s32) = G_SHL [[COPY2]], [[C1]](s32)
334 ; CHECK-NEXT: [[OR:%[0-9]+]]:sreg_32(s32) = G_OR [[AND]], [[SHL]]
335 ; CHECK-NEXT: [[S_BFE_I64_:%[0-9]+]]:sreg_64(s64) = S_BFE_I64 [[COPY]](s64), [[OR]](s32), implicit-def $scc
336 ; CHECK-NEXT: $sgpr0_sgpr1 = COPY [[S_BFE_I64_]](s64)
337 %0:_(s64) = COPY $sgpr0_sgpr1
338 %1:_(s32) = COPY $sgpr0
339 %2:_(s32) = COPY $sgpr1
340 %3:_(s64) = G_SBFX %0, %1(s32), %2
341 $sgpr0_sgpr1 = COPY %3(s64)
345 name: test_sbfx_s64_sii
350 liveins: $sgpr0_sgpr1
352 ; CHECK-LABEL: name: test_sbfx_s64_sii
353 ; CHECK: liveins: $sgpr0_sgpr1
355 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64(s64) = COPY $sgpr0_sgpr1
356 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 1
357 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 10
358 ; CHECK-NEXT: [[C2:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 63
359 ; CHECK-NEXT: [[AND:%[0-9]+]]:sgpr(s32) = G_AND [[C]], [[C2]]
360 ; CHECK-NEXT: [[C3:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 16
361 ; CHECK-NEXT: [[SHL:%[0-9]+]]:sgpr(s32) = G_SHL [[C1]], [[C3]](s32)
362 ; CHECK-NEXT: [[OR:%[0-9]+]]:sreg_32(s32) = G_OR [[AND]], [[SHL]]
363 ; CHECK-NEXT: [[S_BFE_I64_:%[0-9]+]]:sreg_64(s64) = S_BFE_I64 [[COPY]](s64), [[OR]](s32), implicit-def $scc
364 %0:_(s64) = COPY $sgpr0_sgpr1
365 %1:_(s32) = G_CONSTANT i32 1
366 %2:_(s32) = G_CONSTANT i32 10
367 %3:_(s64) = G_SBFX %0, %1(s32), %2