blob: 791b49f0e143ad033cdeec40559b88f9ed2283b0 [file] [log] [blame]
Stanislav Mekhanoshin53a21292017-05-23 19:54:48 +00001; RUN: llc -march=amdgcn -mcpu=fiji < %s | FileCheck --check-prefix=GCN --check-prefix=VI %s
2; RUN: llc -march=amdgcn -mcpu=bonaire < %s | FileCheck --check-prefix=GCN --check-prefix=CI %s
3
4; GCN-LABEL: {{^}}bfe_combine8:
5; VI: v_bfe_u32 v[[BFE:[0-9]+]], v{{[0-9]+}}, 8, 8
6; VI: v_lshlrev_b32_e32 v[[ADDRBASE:[0-9]+]], 2, v[[BFE]]
7; CI: v_lshrrev_b32_e32 v[[SHR:[0-9]+]], 6, v{{[0-9]+}}
8; CI: v_and_b32_e32 v[[ADDRLO:[0-9]+]], 0x3fc, v[[SHR]]
9; VI: v_add_i32_e32 v[[ADDRLO:[0-9]+]], vcc, s{{[0-9]+}}, v[[ADDRBASE]]
10; GCN: load_dword v{{[0-9]+}}, v{{\[}}[[ADDRLO]]:
11define amdgpu_kernel void @bfe_combine8(i32 addrspace(1)* nocapture %arg, i32 %x) {
12 %id = tail call i32 @llvm.amdgcn.workitem.id.x() #2
13 %idx = add i32 %x, %id
14 %srl = lshr i32 %idx, 8
15 %and = and i32 %srl, 255
16 %ptr = getelementptr inbounds i32, i32 addrspace(1)* %arg, i32 %and
17 %val = load i32, i32 addrspace(1)* %ptr, align 4
18 store i32 %val, i32 addrspace(1)* %arg, align 4
19 ret void
20}
21
22; GCN-LABEL: {{^}}bfe_combine16:
23; VI: v_bfe_u32 v[[BFE:[0-9]+]], v{{[0-9]+}}, 16, 16
24; VI: v_lshlrev_b32_e32 v[[ADDRBASE:[0-9]+]], {{[^,]+}}, v[[BFE]]
25; CI: v_lshrrev_b32_e32 v[[SHR:[0-9]+]], 1, v{{[0-9]+}}
26; CI: v_and_b32_e32 v[[AND:[0-9]+]], 0x7fff8000, v[[SHR]]
27; CI: v_lshl_b64 v{{\[}}[[ADDRLO:[0-9]+]]:{{[^\]+}}], v{{\[}}[[AND]]:{{[^\]+}}], 2
28; VI: v_add_i32_e32 v[[ADDRLO:[0-9]+]], vcc, s{{[0-9]+}}, v[[ADDRBASE]]
29; GCN: load_dword v{{[0-9]+}}, v{{\[}}[[ADDRLO]]:
30define amdgpu_kernel void @bfe_combine16(i32 addrspace(1)* nocapture %arg, i32 %x) {
31 %id = tail call i32 @llvm.amdgcn.workitem.id.x() #2
32 %idx = add i32 %x, %id
33 %srl = lshr i32 %idx, 1
34 %and = and i32 %srl, 2147450880
35 %ptr = getelementptr inbounds i32, i32 addrspace(1)* %arg, i32 %and
36 %val = load i32, i32 addrspace(1)* %ptr, align 4
37 store i32 %val, i32 addrspace(1)* %arg, align 4
38 ret void
39}
40
41declare i32 @llvm.amdgcn.workitem.id.x() #1