1 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck %s
3 declare i32 @llvm.amdgcn.ds.bpermute(i32, i32) #0
5 ; FUNC-LABEL: {{^}}ds_bpermute:
6 ; CHECK: ds_bpermute_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
7 define amdgpu_kernel void @ds_bpermute(i32 addrspace(1)* %out, i32 %index, i32 %src) nounwind {
8 %bpermute = call i32 @llvm.amdgcn.ds.bpermute(i32 %index, i32 %src) #0
9 store i32 %bpermute, i32 addrspace(1)* %out, align 4
13 ; CHECK-LABEL: {{^}}ds_bpermute_imm_offset:
14 ; CHECK: ds_bpermute_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset:4
15 define amdgpu_kernel void @ds_bpermute_imm_offset(i32 addrspace(1)* %out, i32 %base_index, i32 %src) nounwind {
16 %index = add i32 %base_index, 4
17 %bpermute = call i32 @llvm.amdgcn.ds.bpermute(i32 %index, i32 %src) #0
18 store i32 %bpermute, i32 addrspace(1)* %out, align 4
22 ; CHECK-LABEL: {{^}}ds_bpermute_imm_index:
23 ; CHECK: ds_bpermute_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset:64
24 define amdgpu_kernel void @ds_bpermute_imm_index(i32 addrspace(1)* %out, i32 %base_index, i32 %src) nounwind {
25 %bpermute = call i32 @llvm.amdgcn.ds.bpermute(i32 64, i32 %src) #0
26 store i32 %bpermute, i32 addrspace(1)* %out, align 4
30 ; CHECK-LABEL: {{^}}ds_bpermute_add_shl:
31 ; CHECK: ds_bpermute_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset:4
32 ; CHECK: s_waitcnt lgkmcnt
33 define void @ds_bpermute_add_shl(i32 addrspace(1)* %out, i32 %base_index, i32 %src) nounwind {
34 %index = add i32 %base_index, 1
35 %byte_index = shl i32 %index, 2
36 %bpermute = call i32 @llvm.amdgcn.ds.bpermute(i32 %byte_index, i32 %src) #0
37 store i32 %bpermute, i32 addrspace(1)* %out, align 4
41 ; CHECK-LABEL: {{^}}ds_bpermute_or_shl:
42 ; CHECK: ds_bpermute_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset:4
43 ; CHECK: s_waitcnt lgkmcnt
44 define void @ds_bpermute_or_shl(i32 addrspace(1)* %out, i32 %base_index, i32 %src) nounwind {
45 %masked = and i32 %base_index, 62
46 %index = or i32 %masked, 1
47 %byte_index = shl i32 %index, 2
48 %bpermute = call i32 @llvm.amdgcn.ds.bpermute(i32 %byte_index, i32 %src) #0
49 store i32 %bpermute, i32 addrspace(1)* %out, align 4
53 attributes #0 = { nounwind readnone convergent }