Update SystemZ/Large test generators to handle new gep IR syntax
[oota-llvm.git] / test / CodeGen / R600 / llvm.AMDGPU.bfe.i32.ll
1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3 ; RUN: llc -march=r600 -mcpu=redwood -show-mc-encoding -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
4
5 declare i32 @llvm.AMDGPU.bfe.i32(i32, i32, i32) nounwind readnone
6
7 ; FUNC-LABEL: {{^}}bfe_i32_arg_arg_arg:
8 ; SI: v_bfe_i32
9 ; EG: BFE_INT
10 ; EG: encoding: [{{[x0-9a-f]+,[x0-9a-f]+,[x0-9a-f]+,[x0-9a-f]+,[x0-9a-f]+}},0xac
11 define void @bfe_i32_arg_arg_arg(i32 addrspace(1)* %out, i32 %src0, i32 %src1, i32 %src2) nounwind {
12   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 %src1, i32 %src1) nounwind readnone
13   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
14   ret void
15 }
16
17 ; FUNC-LABEL: {{^}}bfe_i32_arg_arg_imm:
18 ; SI: v_bfe_i32
19 ; EG: BFE_INT
20 define void @bfe_i32_arg_arg_imm(i32 addrspace(1)* %out, i32 %src0, i32 %src1) nounwind {
21   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 %src1, i32 123) nounwind readnone
22   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
23   ret void
24 }
25
26 ; FUNC-LABEL: {{^}}bfe_i32_arg_imm_arg:
27 ; SI: v_bfe_i32
28 ; EG: BFE_INT
29 define void @bfe_i32_arg_imm_arg(i32 addrspace(1)* %out, i32 %src0, i32 %src2) nounwind {
30   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 123, i32 %src2) nounwind readnone
31   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
32   ret void
33 }
34
35 ; FUNC-LABEL: {{^}}bfe_i32_imm_arg_arg:
36 ; SI: v_bfe_i32
37 ; EG: BFE_INT
38 define void @bfe_i32_imm_arg_arg(i32 addrspace(1)* %out, i32 %src1, i32 %src2) nounwind {
39   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 123, i32 %src1, i32 %src2) nounwind readnone
40   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
41   ret void
42 }
43
44 ; FUNC-LABEL: {{^}}v_bfe_print_arg:
45 ; SI: v_bfe_i32 v{{[0-9]+}}, v{{[0-9]+}}, 2, 8
46 define void @v_bfe_print_arg(i32 addrspace(1)* %out, i32 addrspace(1)* %src0) nounwind {
47   %load = load i32, i32 addrspace(1)* %src0, align 4
48   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %load, i32 2, i32 8) nounwind readnone
49   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
50   ret void
51 }
52
53 ; FUNC-LABEL: {{^}}bfe_i32_arg_0_width_reg_offset:
54 ; SI-NOT: {{[^@]}}bfe
55 ; SI: s_endpgm
56 ; EG-NOT: BFE
57 define void @bfe_i32_arg_0_width_reg_offset(i32 addrspace(1)* %out, i32 %src0, i32 %src1) nounwind {
58   %bfe_u32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 %src1, i32 0) nounwind readnone
59   store i32 %bfe_u32, i32 addrspace(1)* %out, align 4
60   ret void
61 }
62
63 ; FUNC-LABEL: {{^}}bfe_i32_arg_0_width_imm_offset:
64 ; SI-NOT: {{[^@]}}bfe
65 ; SI: s_endpgm
66 ; EG-NOT: BFE
67 define void @bfe_i32_arg_0_width_imm_offset(i32 addrspace(1)* %out, i32 %src0, i32 %src1) nounwind {
68   %bfe_u32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 8, i32 0) nounwind readnone
69   store i32 %bfe_u32, i32 addrspace(1)* %out, align 4
70   ret void
71 }
72
73 ; FUNC-LABEL: {{^}}bfe_i32_test_6:
74 ; SI: v_lshlrev_b32_e32 v{{[0-9]+}}, 31, v{{[0-9]+}}
75 ; SI: v_ashrrev_i32_e32 v{{[0-9]+}}, 1, v{{[0-9]+}}
76 ; SI: s_endpgm
77 define void @bfe_i32_test_6(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
78   %x = load i32, i32 addrspace(1)* %in, align 4
79   %shl = shl i32 %x, 31
80   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %shl, i32 1, i32 31)
81   store i32 %bfe, i32 addrspace(1)* %out, align 4
82   ret void
83 }
84
85 ; FUNC-LABEL: {{^}}bfe_i32_test_7:
86 ; SI-NOT: shl
87 ; SI-NOT: {{[^@]}}bfe
88 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0
89 ; SI: buffer_store_dword [[VREG]],
90 ; SI: s_endpgm
91 define void @bfe_i32_test_7(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
92   %x = load i32, i32 addrspace(1)* %in, align 4
93   %shl = shl i32 %x, 31
94   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %shl, i32 0, i32 31)
95   store i32 %bfe, i32 addrspace(1)* %out, align 4
96   ret void
97 }
98
99 ; FIXME: The shifts should be 1 BFE
100 ; FUNC-LABEL: {{^}}bfe_i32_test_8:
101 ; SI: buffer_load_dword
102 ; SI: v_bfe_i32 v{{[0-9]+}}, v{{[0-9]+}}, 0, 1
103 ; SI: s_endpgm
104 define void @bfe_i32_test_8(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
105   %x = load i32, i32 addrspace(1)* %in, align 4
106   %shl = shl i32 %x, 31
107   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %shl, i32 31, i32 1)
108   store i32 %bfe, i32 addrspace(1)* %out, align 4
109   ret void
110 }
111
112 ; FUNC-LABEL: {{^}}bfe_i32_test_9:
113 ; SI-NOT: {{[^@]}}bfe
114 ; SI: v_ashrrev_i32_e32 v{{[0-9]+}}, 31, v{{[0-9]+}}
115 ; SI-NOT: {{[^@]}}bfe
116 ; SI: s_endpgm
117 define void @bfe_i32_test_9(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
118   %x = load i32, i32 addrspace(1)* %in, align 4
119   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %x, i32 31, i32 1)
120   store i32 %bfe, i32 addrspace(1)* %out, align 4
121   ret void
122 }
123
124 ; FUNC-LABEL: {{^}}bfe_i32_test_10:
125 ; SI-NOT: {{[^@]}}bfe
126 ; SI: v_ashrrev_i32_e32 v{{[0-9]+}}, 1, v{{[0-9]+}}
127 ; SI-NOT: {{[^@]}}bfe
128 ; SI: s_endpgm
129 define void @bfe_i32_test_10(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
130   %x = load i32, i32 addrspace(1)* %in, align 4
131   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %x, i32 1, i32 31)
132   store i32 %bfe, i32 addrspace(1)* %out, align 4
133   ret void
134 }
135
136 ; FUNC-LABEL: {{^}}bfe_i32_test_11:
137 ; SI-NOT: {{[^@]}}bfe
138 ; SI: v_ashrrev_i32_e32 v{{[0-9]+}}, 8, v{{[0-9]+}}
139 ; SI-NOT: {{[^@]}}bfe
140 ; SI: s_endpgm
141 define void @bfe_i32_test_11(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
142   %x = load i32, i32 addrspace(1)* %in, align 4
143   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %x, i32 8, i32 24)
144   store i32 %bfe, i32 addrspace(1)* %out, align 4
145   ret void
146 }
147
148 ; FUNC-LABEL: {{^}}bfe_i32_test_12:
149 ; SI-NOT: {{[^@]}}bfe
150 ; SI: v_ashrrev_i32_e32 v{{[0-9]+}}, 24, v{{[0-9]+}}
151 ; SI-NOT: {{[^@]}}bfe
152 ; SI: s_endpgm
153 define void @bfe_i32_test_12(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
154   %x = load i32, i32 addrspace(1)* %in, align 4
155   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %x, i32 24, i32 8)
156   store i32 %bfe, i32 addrspace(1)* %out, align 4
157   ret void
158 }
159
160 ; FUNC-LABEL: {{^}}bfe_i32_test_13:
161 ; SI: v_ashrrev_i32_e32 {{v[0-9]+}}, 31, {{v[0-9]+}}
162 ; SI-NOT: {{[^@]}}bfe
163 ; SI: s_endpgm
164 define void @bfe_i32_test_13(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
165   %x = load i32, i32 addrspace(1)* %in, align 4
166   %shl = ashr i32 %x, 31
167   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %shl, i32 31, i32 1)
168   store i32 %bfe, i32 addrspace(1)* %out, align 4 ret void
169 }
170
171 ; FUNC-LABEL: {{^}}bfe_i32_test_14:
172 ; SI-NOT: lshr
173 ; SI-NOT: {{[^@]}}bfe
174 ; SI: s_endpgm
175 define void @bfe_i32_test_14(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
176   %x = load i32, i32 addrspace(1)* %in, align 4
177   %shl = lshr i32 %x, 31
178   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %shl, i32 31, i32 1)
179   store i32 %bfe, i32 addrspace(1)* %out, align 4 ret void
180 }
181
182 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_0:
183 ; SI-NOT: {{[^@]}}bfe
184 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0
185 ; SI: buffer_store_dword [[VREG]],
186 ; SI: s_endpgm
187 ; EG-NOT: BFE
188 define void @bfe_i32_constant_fold_test_0(i32 addrspace(1)* %out) nounwind {
189   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 0, i32 0, i32 0) nounwind readnone
190   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
191   ret void
192 }
193
194 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_1:
195 ; SI-NOT: {{[^@]}}bfe
196 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0
197 ; SI: buffer_store_dword [[VREG]],
198 ; SI: s_endpgm
199 ; EG-NOT: BFE
200 define void @bfe_i32_constant_fold_test_1(i32 addrspace(1)* %out) nounwind {
201   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 12334, i32 0, i32 0) nounwind readnone
202   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
203   ret void
204 }
205
206 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_2:
207 ; SI-NOT: {{[^@]}}bfe
208 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0
209 ; SI: buffer_store_dword [[VREG]],
210 ; SI: s_endpgm
211 ; EG-NOT: BFE
212 define void @bfe_i32_constant_fold_test_2(i32 addrspace(1)* %out) nounwind {
213   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 0, i32 0, i32 1) nounwind readnone
214   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
215   ret void
216 }
217
218 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_3:
219 ; SI-NOT: {{[^@]}}bfe
220 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], -1
221 ; SI: buffer_store_dword [[VREG]],
222 ; SI: s_endpgm
223 ; EG-NOT: BFE
224 define void @bfe_i32_constant_fold_test_3(i32 addrspace(1)* %out) nounwind {
225   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 1, i32 0, i32 1) nounwind readnone
226   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
227   ret void
228 }
229
230 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_4:
231 ; SI-NOT: {{[^@]}}bfe
232 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], -1
233 ; SI: buffer_store_dword [[VREG]],
234 ; SI: s_endpgm
235 ; EG-NOT: BFE
236 define void @bfe_i32_constant_fold_test_4(i32 addrspace(1)* %out) nounwind {
237   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 4294967295, i32 0, i32 1) nounwind readnone
238   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
239   ret void
240 }
241
242 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_5:
243 ; SI-NOT: {{[^@]}}bfe
244 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], -1
245 ; SI: buffer_store_dword [[VREG]],
246 ; SI: s_endpgm
247 ; EG-NOT: BFE
248 define void @bfe_i32_constant_fold_test_5(i32 addrspace(1)* %out) nounwind {
249   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 128, i32 7, i32 1) nounwind readnone
250   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
251   ret void
252 }
253
254 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_6:
255 ; SI-NOT: {{[^@]}}bfe
256 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0xffffff80
257 ; SI: buffer_store_dword [[VREG]],
258 ; SI: s_endpgm
259 ; EG-NOT: BFE
260 define void @bfe_i32_constant_fold_test_6(i32 addrspace(1)* %out) nounwind {
261   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 128, i32 0, i32 8) nounwind readnone
262   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
263   ret void
264 }
265
266 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_7:
267 ; SI-NOT: {{[^@]}}bfe
268 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0x7f
269 ; SI: buffer_store_dword [[VREG]],
270 ; SI: s_endpgm
271 ; EG-NOT: BFE
272 define void @bfe_i32_constant_fold_test_7(i32 addrspace(1)* %out) nounwind {
273   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 127, i32 0, i32 8) nounwind readnone
274   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
275   ret void
276 }
277
278 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_8:
279 ; SI-NOT: {{[^@]}}bfe
280 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 1
281 ; SI: buffer_store_dword [[VREG]],
282 ; SI: s_endpgm
283 ; EG-NOT: BFE
284 define void @bfe_i32_constant_fold_test_8(i32 addrspace(1)* %out) nounwind {
285   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 127, i32 6, i32 8) nounwind readnone
286   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
287   ret void
288 }
289
290 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_9:
291 ; SI-NOT: {{[^@]}}bfe
292 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 1
293 ; SI: buffer_store_dword [[VREG]],
294 ; SI: s_endpgm
295 ; EG-NOT: BFE
296 define void @bfe_i32_constant_fold_test_9(i32 addrspace(1)* %out) nounwind {
297   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 65536, i32 16, i32 8) nounwind readnone
298   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
299   ret void
300 }
301
302 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_10:
303 ; SI-NOT: {{[^@]}}bfe
304 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0
305 ; SI: buffer_store_dword [[VREG]],
306 ; SI: s_endpgm
307 ; EG-NOT: BFE
308 define void @bfe_i32_constant_fold_test_10(i32 addrspace(1)* %out) nounwind {
309   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 65535, i32 16, i32 16) nounwind readnone
310   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
311   ret void
312 }
313
314 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_11:
315 ; SI-NOT: {{[^@]}}bfe
316 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], -6
317 ; SI: buffer_store_dword [[VREG]],
318 ; SI: s_endpgm
319 ; EG-NOT: BFE
320 define void @bfe_i32_constant_fold_test_11(i32 addrspace(1)* %out) nounwind {
321   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 160, i32 4, i32 4) nounwind readnone
322   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
323   ret void
324 }
325
326 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_12:
327 ; SI-NOT: {{[^@]}}bfe
328 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0
329 ; SI: buffer_store_dword [[VREG]],
330 ; SI: s_endpgm
331 ; EG-NOT: BFE
332 define void @bfe_i32_constant_fold_test_12(i32 addrspace(1)* %out) nounwind {
333   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 160, i32 31, i32 1) nounwind readnone
334   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
335   ret void
336 }
337
338 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_13:
339 ; SI-NOT: {{[^@]}}bfe
340 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 1
341 ; SI: buffer_store_dword [[VREG]],
342 ; SI: s_endpgm
343 ; EG-NOT: BFE
344 define void @bfe_i32_constant_fold_test_13(i32 addrspace(1)* %out) nounwind {
345   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 131070, i32 16, i32 16) nounwind readnone
346   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
347   ret void
348 }
349
350 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_14:
351 ; SI-NOT: {{[^@]}}bfe
352 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 40
353 ; SI: buffer_store_dword [[VREG]],
354 ; SI: s_endpgm
355 ; EG-NOT: BFE
356 define void @bfe_i32_constant_fold_test_14(i32 addrspace(1)* %out) nounwind {
357   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 160, i32 2, i32 30) nounwind readnone
358   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
359   ret void
360 }
361
362 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_15:
363 ; SI-NOT: {{[^@]}}bfe
364 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 10
365 ; SI: buffer_store_dword [[VREG]],
366 ; SI: s_endpgm
367 ; EG-NOT: BFE
368 define void @bfe_i32_constant_fold_test_15(i32 addrspace(1)* %out) nounwind {
369   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 160, i32 4, i32 28) nounwind readnone
370   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
371   ret void
372 }
373
374 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_16:
375 ; SI-NOT: {{[^@]}}bfe
376 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], -1
377 ; SI: buffer_store_dword [[VREG]],
378 ; SI: s_endpgm
379 ; EG-NOT: BFE
380 define void @bfe_i32_constant_fold_test_16(i32 addrspace(1)* %out) nounwind {
381   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 4294967295, i32 1, i32 7) nounwind readnone
382   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
383   ret void
384 }
385
386 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_17:
387 ; SI-NOT: {{[^@]}}bfe
388 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0x7f
389 ; SI: buffer_store_dword [[VREG]],
390 ; SI: s_endpgm
391 ; EG-NOT: BFE
392 define void @bfe_i32_constant_fold_test_17(i32 addrspace(1)* %out) nounwind {
393   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 255, i32 1, i32 31) nounwind readnone
394   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
395   ret void
396 }
397
398 ; FUNC-LABEL: {{^}}bfe_i32_constant_fold_test_18:
399 ; SI-NOT: {{[^@]}}bfe
400 ; SI: v_mov_b32_e32 [[VREG:v[0-9]+]], 0
401 ; SI: buffer_store_dword [[VREG]],
402 ; SI: s_endpgm
403 ; EG-NOT: BFE
404 define void @bfe_i32_constant_fold_test_18(i32 addrspace(1)* %out) nounwind {
405   %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 255, i32 31, i32 1) nounwind readnone
406   store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
407   ret void
408 }
409
410 ; XXX - This should really be a single BFE, but the sext_inreg of the
411 ; extended type i24 is never custom lowered.
412 ; FUNC-LABEL: {{^}}bfe_sext_in_reg_i24:
413 ; SI: buffer_load_dword [[LOAD:v[0-9]+]],
414 ; SI: v_lshlrev_b32_e32 {{v[0-9]+}}, 8, {{v[0-9]+}}
415 ; SI: v_ashrrev_i32_e32 {{v[0-9]+}}, 8, {{v[0-9]+}}
416 ; XSI: v_bfe_i32 [[BFE:v[0-9]+]], [[LOAD]], 0, 8
417 ; XSI-NOT: SHL
418 ; XSI-NOT: SHR
419 ; XSI: buffer_store_dword [[BFE]],
420 define void @bfe_sext_in_reg_i24(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
421   %x = load i32, i32 addrspace(1)* %in, align 4
422   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %x, i32 0, i32 24)
423   %shl = shl i32 %bfe, 8
424   %ashr = ashr i32 %shl, 8
425   store i32 %ashr, i32 addrspace(1)* %out, align 4
426   ret void
427 }
428
429 ; FUNC-LABEL: @simplify_demanded_bfe_sdiv
430 ; SI: buffer_load_dword [[LOAD:v[0-9]+]]
431 ; SI: v_bfe_i32 [[BFE:v[0-9]+]], [[LOAD]], 1, 16
432 ; SI: v_lshrrev_b32_e32 [[TMP0:v[0-9]+]], 31, [[BFE]]
433 ; SI: v_add_i32_e32 [[TMP1:v[0-9]+]], [[TMP0]], [[BFE]]
434 ; SI: v_ashrrev_i32_e32 [[TMP2:v[0-9]+]], 1, [[TMP1]]
435 ; SI: buffer_store_dword [[TMP2]]
436 define void @simplify_demanded_bfe_sdiv(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
437   %src = load i32, i32 addrspace(1)* %in, align 4
438   %bfe = call i32 @llvm.AMDGPU.bfe.i32(i32 %src, i32 1, i32 16) nounwind readnone
439   %div = sdiv i32 %bfe, 2
440   store i32 %div, i32 addrspace(1)* %out, align 4
441   ret void
442 }