1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -mcpu=fiji -run-pass=amdgpu-regbankselect -regbankselect-fast -verify-machineinstrs -o - %s | FileCheck %s
3 # RUN: llc -march=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_ubfx_s32_vvv
15 liveins: $vgpr0, $vgpr1, $vgpr2
17 ; CHECK-LABEL: name: test_ubfx_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: [[UBFX:%[0-9]+]]:vgpr(s32) = G_UBFX [[COPY]], [[COPY1]](s32), [[COPY2]]
24 ; CHECK-NEXT: $vgpr0 = COPY [[UBFX]](s32)
25 %0:_(s32) = COPY $vgpr0
26 %1:_(s32) = COPY $vgpr1
27 %2:_(s32) = COPY $vgpr2
28 %3:_(s32) = G_UBFX %0, %1(s32), %2
33 name: test_ubfx_s32_vii
40 ; CHECK-LABEL: name: test_ubfx_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: [[UBFX:%[0-9]+]]:vgpr(s32) = G_UBFX [[COPY]], [[COPY1]](s32), [[COPY2]]
49 ; CHECK-NEXT: $vgpr0 = COPY [[UBFX]](s32)
50 %0:_(s32) = COPY $vgpr0
51 %1:_(s32) = G_CONSTANT i32 10
52 %2:_(s32) = G_CONSTANT i32 4
53 %3:_(s32) = G_UBFX %0, %1(s32), %2
58 name: test_ubfx_s32_vss
63 liveins: $vgpr0, $sgpr0, $sgpr1
65 ; CHECK-LABEL: name: test_ubfx_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: [[UBFX:%[0-9]+]]:vgpr(s32) = G_UBFX [[COPY]], [[COPY3]](s32), [[COPY4]]
74 ; CHECK-NEXT: $vgpr0 = COPY [[UBFX]](s32)
75 %0:_(s32) = COPY $vgpr0
76 %1:_(s32) = COPY $sgpr0
77 %2:_(s32) = COPY $sgpr1
78 %3:_(s32) = G_UBFX %0, %1(s32), %2
82 # Expand to a sequence that implements the 64-bit bitfield extract using
85 name: test_ubfx_s64_vvv
90 liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3
92 ; CHECK-LABEL: name: test_ubfx_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: [[LSHR:%[0-9]+]]:vgpr(s64) = G_LSHR [[COPY]], [[COPY1]](s32)
99 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[LSHR]](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 [[LSHR]], [[SUB]](s32)
103 ; CHECK-NEXT: [[LSHR1:%[0-9]+]]:vgpr(s64) = G_LSHR [[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_UBFX %0, %1(s32), %2
109 $vgpr0_vgpr1 = COPY %3(s64)
113 name: test_ubfx_s64_vss
118 liveins: $vgpr0_vgpr1, $sgpr0, $sgpr1
120 ; CHECK-LABEL: name: test_ubfx_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: [[LSHR:%[0-9]+]]:vgpr(s64) = G_LSHR [[COPY]], [[COPY1]](s32)
127 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[LSHR]](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 [[LSHR]], [[SUB]](s32)
131 ; CHECK-NEXT: [[LSHR1:%[0-9]+]]:vgpr(s64) = G_LSHR [[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_UBFX %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_ubfx_s64_vii_small
148 liveins: $vgpr0_vgpr1
150 ; CHECK-LABEL: name: test_ubfx_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: [[LSHR:%[0-9]+]]:vgpr(s64) = G_LSHR [[COPY]], [[COPY1]](s32)
159 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[LSHR]](s64)
160 ; CHECK-NEXT: [[C2:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 0
161 ; CHECK-NEXT: [[UBFX:%[0-9]+]]:vgpr(s32) = G_UBFX [[UV]], [[C2]](s32), [[COPY2]]
162 ; CHECK-NEXT: [[MV:%[0-9]+]]:vgpr(s64) = G_MERGE_VALUES [[UBFX]](s32), [[C2]](s32)
163 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[MV]](s64)
164 %0:_(s64) = COPY $vgpr0_vgpr1
165 %1:_(s32) = G_CONSTANT i32 31
166 %2:_(s32) = G_CONSTANT i32 4
167 %3:_(s64) = G_UBFX %0, %1(s32), %2
168 $vgpr0_vgpr1 = COPY %3(s64)
172 name: test_ubfx_s64_vii_big
177 liveins: $vgpr0_vgpr1
179 ; CHECK-LABEL: name: test_ubfx_s64_vii_big
180 ; CHECK: liveins: $vgpr0_vgpr1
182 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s64) = COPY $vgpr0_vgpr1
183 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 8
184 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 40
185 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32)
186 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[C1]](s32)
187 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:vgpr(s64) = G_LSHR [[COPY]], [[COPY1]](s32)
188 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[LSHR]](s64)
189 ; CHECK-NEXT: [[C2:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 0
190 ; CHECK-NEXT: [[C3:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 8
191 ; CHECK-NEXT: [[UBFX:%[0-9]+]]:vgpr(s32) = G_UBFX [[UV1]], [[C2]](s32), [[C3]]
192 ; CHECK-NEXT: [[MV:%[0-9]+]]:vgpr(s64) = G_MERGE_VALUES [[UV]](s32), [[UBFX]](s32)
193 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[MV]](s64)
194 %0:_(s64) = COPY $vgpr0_vgpr1
195 %1:_(s32) = G_CONSTANT i32 8
196 %2:_(s32) = G_CONSTANT i32 40
197 %3:_(s64) = G_UBFX %0, %1(s32), %2
198 $vgpr0_vgpr1 = COPY %3(s64)
202 name: test_ubfx_s64_svv
207 liveins: $sgpr0_sgpr1, $vgpr0, $vgpr1
209 ; CHECK-LABEL: name: test_ubfx_s64_svv
210 ; CHECK: liveins: $sgpr0_sgpr1, $vgpr0, $vgpr1
212 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sgpr(s64) = COPY $sgpr0_sgpr1
213 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
214 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY $vgpr1
215 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vgpr(s64) = COPY [[COPY]](s64)
216 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:vgpr(s64) = G_LSHR [[COPY3]], [[COPY1]](s32)
217 ; CHECK-NEXT: [[UV:%[0-9]+]]:vgpr(s32), [[UV1:%[0-9]+]]:vgpr(s32) = G_UNMERGE_VALUES [[LSHR]](s64)
218 ; CHECK-NEXT: [[C:%[0-9]+]]:vgpr(s32) = G_CONSTANT i32 64
219 ; CHECK-NEXT: [[SUB:%[0-9]+]]:vgpr(s32) = G_SUB [[C]], [[COPY2]]
220 ; CHECK-NEXT: [[SHL:%[0-9]+]]:vgpr(s64) = G_SHL [[LSHR]], [[SUB]](s32)
221 ; CHECK-NEXT: [[LSHR1:%[0-9]+]]:vgpr(s64) = G_LSHR [[SHL]], [[SUB]](s32)
222 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY %3:vgpr(s64)
223 %0:_(s64) = COPY $sgpr0_sgpr1
224 %1:_(s32) = COPY $vgpr0
225 %2:_(s32) = COPY $vgpr1
226 %3:_(s64) = G_UBFX %0, %1(s32), %2
227 $vgpr0_vgpr1 = COPY %3(s64)
230 # Expand to a sequence that combines the offset and width for the two operand
231 # version of the 32-bit instruction.
233 name: test_ubfx_s32_svv
238 liveins: $sgpr0, $vgpr0, $vgpr1
240 ; CHECK-LABEL: name: test_ubfx_s32_svv
241 ; CHECK: liveins: $sgpr0, $vgpr0, $vgpr1
243 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
244 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
245 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY $vgpr1
246 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[COPY]](s32)
247 ; CHECK-NEXT: [[UBFX:%[0-9]+]]:vgpr(s32) = G_UBFX [[COPY3]], [[COPY1]](s32), [[COPY2]]
248 ; CHECK-NEXT: $vgpr0 = COPY [[UBFX]](s32)
249 %0:_(s32) = COPY $sgpr0
250 %1:_(s32) = COPY $vgpr0
251 %2:_(s32) = COPY $vgpr1
252 %3:_(s32) = G_UBFX %0, %1(s32), %2
253 $vgpr0 = COPY %3(s32)
257 name: test_ubfx_s32_sss
262 liveins: $sgpr0, $sgpr1, $sgpr2
264 ; CHECK-LABEL: name: test_ubfx_s32_sss
265 ; CHECK: liveins: $sgpr0, $sgpr1, $sgpr2
267 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32(s32) = COPY $sgpr0
268 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
269 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr2
270 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 63
271 ; CHECK-NEXT: [[AND:%[0-9]+]]:sgpr(s32) = G_AND [[COPY1]], [[C]]
272 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 16
273 ; CHECK-NEXT: [[SHL:%[0-9]+]]:sgpr(s32) = G_SHL [[COPY2]], [[C1]](s32)
274 ; CHECK-NEXT: [[OR:%[0-9]+]]:sreg_32(s32) = G_OR [[AND]], [[SHL]]
275 ; CHECK-NEXT: [[S_BFE_U32_:%[0-9]+]]:sreg_32(s32) = S_BFE_U32 [[COPY]](s32), [[OR]](s32), implicit-def $scc
276 ; CHECK-NEXT: $sgpr0 = COPY [[S_BFE_U32_]](s32)
277 %0:_(s32) = COPY $sgpr0
278 %1:_(s32) = COPY $sgpr1
279 %2:_(s32) = COPY $sgpr2
280 %3:_(s32) = G_UBFX %0, %1(s32), %2
281 $sgpr0 = COPY %3(s32)
285 name: test_ubfx_s32_sii
290 liveins: $sgpr0, $sgpr1, $sgpr2
292 ; CHECK-LABEL: name: test_ubfx_s32_sii
293 ; CHECK: liveins: $sgpr0, $sgpr1, $sgpr2
295 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32(s32) = COPY $sgpr0
296 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 1
297 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 10
298 ; CHECK-NEXT: [[C2:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 63
299 ; CHECK-NEXT: [[AND:%[0-9]+]]:sgpr(s32) = G_AND [[C]], [[C2]]
300 ; CHECK-NEXT: [[C3:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 16
301 ; CHECK-NEXT: [[SHL:%[0-9]+]]:sgpr(s32) = G_SHL [[C1]], [[C3]](s32)
302 ; CHECK-NEXT: [[OR:%[0-9]+]]:sreg_32(s32) = G_OR [[AND]], [[SHL]]
303 ; CHECK-NEXT: [[S_BFE_U32_:%[0-9]+]]:sreg_32(s32) = S_BFE_U32 [[COPY]](s32), [[OR]](s32), implicit-def $scc
304 ; CHECK-NEXT: $sgpr0 = COPY [[S_BFE_U32_]](s32)
305 %0:_(s32) = COPY $sgpr0
306 %1:_(s32) = G_CONSTANT i32 1
307 %2:_(s32) = G_CONSTANT i32 10
308 %3:_(s32) = G_UBFX %0, %1(s32), %2
309 $sgpr0 = COPY %3(s32)
312 # Expand to a sequence that combines the offset and width for the two operand
313 # version of the 64-bit scalar instruction.
315 name: test_ubfx_s64_sss
320 liveins: $sgpr0_sgpr1, $sgpr2, $sgpr3
322 ; CHECK-LABEL: name: test_ubfx_s64_sss
323 ; CHECK: liveins: $sgpr0_sgpr1, $sgpr2, $sgpr3
325 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64(s64) = COPY $sgpr0_sgpr1
326 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr2
327 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr3
328 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 63
329 ; CHECK-NEXT: [[AND:%[0-9]+]]:sgpr(s32) = G_AND [[COPY1]], [[C]]
330 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 16
331 ; CHECK-NEXT: [[SHL:%[0-9]+]]:sgpr(s32) = G_SHL [[COPY2]], [[C1]](s32)
332 ; CHECK-NEXT: [[OR:%[0-9]+]]:sreg_32(s32) = G_OR [[AND]], [[SHL]]
333 ; CHECK-NEXT: [[S_BFE_U64_:%[0-9]+]]:sreg_64(s64) = S_BFE_U64 [[COPY]](s64), [[OR]](s32), implicit-def $scc
334 ; CHECK-NEXT: $sgpr0_sgpr1 = COPY [[S_BFE_U64_]](s64)
335 %0:_(s64) = COPY $sgpr0_sgpr1
336 %1:_(s32) = COPY $sgpr2
337 %2:_(s32) = COPY $sgpr3
338 %3:_(s64) = G_UBFX %0, %1(s32), %2
339 $sgpr0_sgpr1 = COPY %3(s64)
343 name: test_ubfx_s64_sii
348 liveins: $sgpr0_sgpr1
350 ; CHECK-LABEL: name: test_ubfx_s64_sii
351 ; CHECK: liveins: $sgpr0_sgpr1
353 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64(s64) = COPY $sgpr0_sgpr1
354 ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 1
355 ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 10
356 ; CHECK-NEXT: [[C2:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 63
357 ; CHECK-NEXT: [[AND:%[0-9]+]]:sgpr(s32) = G_AND [[C]], [[C2]]
358 ; CHECK-NEXT: [[C3:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 16
359 ; CHECK-NEXT: [[SHL:%[0-9]+]]:sgpr(s32) = G_SHL [[C1]], [[C3]](s32)
360 ; CHECK-NEXT: [[OR:%[0-9]+]]:sreg_32(s32) = G_OR [[AND]], [[SHL]]
361 ; CHECK-NEXT: [[S_BFE_U64_:%[0-9]+]]:sreg_64(s64) = S_BFE_U64 [[COPY]](s64), [[OR]](s32), implicit-def $scc
362 ; CHECK-NEXT: $sgpr0_sgpr1 = COPY [[S_BFE_U64_]](s64)
363 %0:_(s64) = COPY $sgpr0_sgpr1
364 %1:_(s32) = G_CONSTANT i32 1
365 %2:_(s32) = G_CONSTANT i32 10
366 %3:_(s64) = G_UBFX %0, %1(s32), %2
367 $sgpr0_sgpr1 = COPY %3(s64)