1 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=r600 -mcpu=redwood -show-mc-encoding -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
4 declare i32 @llvm.AMDGPU.bfe.i32(i32, i32, i32) nounwind readnone
6 ; FUNC-LABEL: @bfe_i32_arg_arg_arg
9 ; EG: encoding: [{{[x0-9a-f]+,[x0-9a-f]+,[x0-9a-f]+,[x0-9a-f]+,[x0-9a-f]+}},0xac
10 define void @bfe_i32_arg_arg_arg(i32 addrspace(1)* %out, i32 %src0, i32 %src1, i32 %src2) nounwind {
11 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 %src1, i32 %src1) nounwind readnone
12 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
16 ; FUNC-LABEL: @bfe_i32_arg_arg_imm
19 define void @bfe_i32_arg_arg_imm(i32 addrspace(1)* %out, i32 %src0, i32 %src1) nounwind {
20 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 %src1, i32 123) nounwind readnone
21 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
25 ; FUNC-LABEL: @bfe_i32_arg_imm_arg
28 define void @bfe_i32_arg_imm_arg(i32 addrspace(1)* %out, i32 %src0, i32 %src2) nounwind {
29 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 123, i32 %src2) nounwind readnone
30 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
34 ; FUNC-LABEL: @bfe_i32_imm_arg_arg
37 define void @bfe_i32_imm_arg_arg(i32 addrspace(1)* %out, i32 %src1, i32 %src2) nounwind {
38 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 123, i32 %src1, i32 %src2) nounwind readnone
39 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
43 ; FUNC-LABEL: @v_bfe_print_arg
44 ; SI: V_BFE_I32 v{{[0-9]+}}, v{{[0-9]+}}, 2, 8
45 define void @v_bfe_print_arg(i32 addrspace(1)* %out, i32 addrspace(1)* %src0) nounwind {
46 %load = load i32 addrspace(1)* %src0, align 4
47 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %load, i32 2, i32 8) nounwind readnone
48 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
52 ; FUNC-LABEL: @bfe_i32_arg_0_width_reg_offset
56 define void @bfe_i32_arg_0_width_reg_offset(i32 addrspace(1)* %out, i32 %src0, i32 %src1) nounwind {
57 %bfe_u32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 %src1, i32 0) nounwind readnone
58 store i32 %bfe_u32, i32 addrspace(1)* %out, align 4
62 ; FUNC-LABEL: @bfe_i32_arg_0_width_imm_offset
66 define void @bfe_i32_arg_0_width_imm_offset(i32 addrspace(1)* %out, i32 %src0, i32 %src1) nounwind {
67 %bfe_u32 = call i32 @llvm.AMDGPU.bfe.i32(i32 %src0, i32 8, i32 0) nounwind readnone
68 store i32 %bfe_u32, i32 addrspace(1)* %out, align 4
72 ; FUNC-LABEL: @bfe_i32_constant_fold_test_0
74 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 0
75 ; SI: BUFFER_STORE_DWORD [[VREG]],
78 define void @bfe_i32_constant_fold_test_0(i32 addrspace(1)* %out) nounwind {
79 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 0, i32 0, i32 0) nounwind readnone
80 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
84 ; FUNC-LABEL: @bfe_i32_constant_fold_test_1
86 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 0
87 ; SI: BUFFER_STORE_DWORD [[VREG]],
90 define void @bfe_i32_constant_fold_test_1(i32 addrspace(1)* %out) nounwind {
91 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 12334, i32 0, i32 0) nounwind readnone
92 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
96 ; FUNC-LABEL: @bfe_i32_constant_fold_test_2
98 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 0
99 ; SI: BUFFER_STORE_DWORD [[VREG]],
102 define void @bfe_i32_constant_fold_test_2(i32 addrspace(1)* %out) nounwind {
103 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 0, i32 0, i32 1) nounwind readnone
104 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
108 ; FUNC-LABEL: @bfe_i32_constant_fold_test_3
110 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], -1
111 ; SI: BUFFER_STORE_DWORD [[VREG]],
114 define void @bfe_i32_constant_fold_test_3(i32 addrspace(1)* %out) nounwind {
115 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 1, i32 0, i32 1) nounwind readnone
116 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
120 ; FUNC-LABEL: @bfe_i32_constant_fold_test_4
122 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], -1
123 ; SI: BUFFER_STORE_DWORD [[VREG]],
126 define void @bfe_i32_constant_fold_test_4(i32 addrspace(1)* %out) nounwind {
127 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 4294967295, i32 0, i32 1) nounwind readnone
128 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
132 ; FUNC-LABEL: @bfe_i32_constant_fold_test_5
134 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], -1
135 ; SI: BUFFER_STORE_DWORD [[VREG]],
138 define void @bfe_i32_constant_fold_test_5(i32 addrspace(1)* %out) nounwind {
139 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 128, i32 7, i32 1) nounwind readnone
140 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
144 ; FUNC-LABEL: @bfe_i32_constant_fold_test_6
146 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 0xffffff80
147 ; SI: BUFFER_STORE_DWORD [[VREG]],
150 define void @bfe_i32_constant_fold_test_6(i32 addrspace(1)* %out) nounwind {
151 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 128, i32 0, i32 8) nounwind readnone
152 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
156 ; FUNC-LABEL: @bfe_i32_constant_fold_test_7
158 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 0x7f
159 ; SI: BUFFER_STORE_DWORD [[VREG]],
162 define void @bfe_i32_constant_fold_test_7(i32 addrspace(1)* %out) nounwind {
163 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 127, i32 0, i32 8) nounwind readnone
164 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
168 ; FUNC-LABEL: @bfe_i32_constant_fold_test_8
170 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 1
171 ; SI: BUFFER_STORE_DWORD [[VREG]],
174 define void @bfe_i32_constant_fold_test_8(i32 addrspace(1)* %out) nounwind {
175 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 127, i32 6, i32 8) nounwind readnone
176 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
180 ; FUNC-LABEL: @bfe_i32_constant_fold_test_9
182 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 1
183 ; SI: BUFFER_STORE_DWORD [[VREG]],
186 define void @bfe_i32_constant_fold_test_9(i32 addrspace(1)* %out) nounwind {
187 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 65536, i32 16, i32 8) nounwind readnone
188 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
192 ; FUNC-LABEL: @bfe_i32_constant_fold_test_10
194 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 0
195 ; SI: BUFFER_STORE_DWORD [[VREG]],
198 define void @bfe_i32_constant_fold_test_10(i32 addrspace(1)* %out) nounwind {
199 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 65535, i32 16, i32 16) nounwind readnone
200 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
204 ; FUNC-LABEL: @bfe_i32_constant_fold_test_11
206 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], -6
207 ; SI: BUFFER_STORE_DWORD [[VREG]],
210 define void @bfe_i32_constant_fold_test_11(i32 addrspace(1)* %out) nounwind {
211 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 160, i32 4, i32 4) nounwind readnone
212 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
216 ; FUNC-LABEL: @bfe_i32_constant_fold_test_12
218 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 0
219 ; SI: BUFFER_STORE_DWORD [[VREG]],
222 define void @bfe_i32_constant_fold_test_12(i32 addrspace(1)* %out) nounwind {
223 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 160, i32 31, i32 1) nounwind readnone
224 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
228 ; FUNC-LABEL: @bfe_i32_constant_fold_test_13
230 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 1
231 ; SI: BUFFER_STORE_DWORD [[VREG]],
234 define void @bfe_i32_constant_fold_test_13(i32 addrspace(1)* %out) nounwind {
235 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 131070, i32 16, i32 16) nounwind readnone
236 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
240 ; FUNC-LABEL: @bfe_i32_constant_fold_test_14
242 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 40
243 ; SI: BUFFER_STORE_DWORD [[VREG]],
246 define void @bfe_i32_constant_fold_test_14(i32 addrspace(1)* %out) nounwind {
247 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 160, i32 2, i32 30) nounwind readnone
248 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
252 ; FUNC-LABEL: @bfe_i32_constant_fold_test_15
254 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 10
255 ; SI: BUFFER_STORE_DWORD [[VREG]],
258 define void @bfe_i32_constant_fold_test_15(i32 addrspace(1)* %out) nounwind {
259 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 160, i32 4, i32 28) nounwind readnone
260 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
264 ; FUNC-LABEL: @bfe_i32_constant_fold_test_16
266 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], -1
267 ; SI: BUFFER_STORE_DWORD [[VREG]],
270 define void @bfe_i32_constant_fold_test_16(i32 addrspace(1)* %out) nounwind {
271 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 4294967295, i32 1, i32 7) nounwind readnone
272 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
276 ; FUNC-LABEL: @bfe_i32_constant_fold_test_17
278 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 0x7f
279 ; SI: BUFFER_STORE_DWORD [[VREG]],
282 define void @bfe_i32_constant_fold_test_17(i32 addrspace(1)* %out) nounwind {
283 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 255, i32 1, i32 31) nounwind readnone
284 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4
288 ; FUNC-LABEL: @bfe_i32_constant_fold_test_18
290 ; SI: V_MOV_B32_e32 [[VREG:v[0-9]+]], 0
291 ; SI: BUFFER_STORE_DWORD [[VREG]],
294 define void @bfe_i32_constant_fold_test_18(i32 addrspace(1)* %out) nounwind {
295 %bfe_i32 = call i32 @llvm.AMDGPU.bfe.i32(i32 255, i32 31, i32 1) nounwind readnone
296 store i32 %bfe_i32, i32 addrspace(1)* %out, align 4