1 ; FIXME: Need to add support for mubuf stores to enable this on SI.
2 ; XUN: llc < %s -march=amdgcn -mcpu=tahiti -show-mc-encoding -verify-machineinstrs -global-isel | FileCheck --check-prefix=SI --check-prefix=GCN --check-prefix=SIVI %s
3 ; RUN: llc < %s -march=amdgcn -mcpu=bonaire -show-mc-encoding -verify-machineinstrs -global-isel | FileCheck --check-prefix=CI --check-prefix=GCN %s
4 ; RUN: llc < %s -march=amdgcn -mcpu=tonga -show-mc-encoding -verify-machineinstrs -global-isel | FileCheck --check-prefix=VI --check-prefix=GCN --check-prefix=SIVI %s
6 ; SMRD load with an immediate offset.
7 ; GCN-LABEL: {{^}}smrd0:
8 ; SICI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x1 ; encoding: [0x01
9 ; VI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x4
10 define amdgpu_kernel void @smrd0(i32 addrspace(4)* %ptr) {
12 %0 = getelementptr i32, i32 addrspace(4)* %ptr, i64 1
13 %1 = load i32, i32 addrspace(4)* %0
14 store i32 %1, i32 addrspace(1)* undef
18 ; SMRD load with the largest possible immediate offset.
19 ; GCN-LABEL: {{^}}smrd1:
20 ; SICI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0xff ; encoding: [0xff,0x{{[0-9]+[137]}}
21 ; VI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x3fc
22 define amdgpu_kernel void @smrd1(i32 addrspace(4)* %ptr) {
24 %0 = getelementptr i32, i32 addrspace(4)* %ptr, i64 255
25 %1 = load i32, i32 addrspace(4)* %0
26 store i32 %1, i32 addrspace(1)* undef
30 ; SMRD load with an offset greater than the largest possible immediate.
31 ; GCN-LABEL: {{^}}smrd2:
32 ; SI: s_movk_i32 s[[OFFSET:[0-9]]], 0x400
33 ; SI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], s[[OFFSET]] ; encoding: [0x0[[OFFSET]]
34 ; CI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x100
35 ; VI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x400
37 define amdgpu_kernel void @smrd2(i32 addrspace(4)* %ptr) {
39 %0 = getelementptr i32, i32 addrspace(4)* %ptr, i64 256
40 %1 = load i32, i32 addrspace(4)* %0
41 store i32 %1, i32 addrspace(1)* undef
45 ; SMRD load with a 64-bit offset
46 ; GCN-LABEL: {{^}}smrd3:
47 ; FIXME: There are too many copies here because we don't fold immediates
48 ; through REG_SEQUENCE
49 ; XSI: s_load_dwordx2 s[{{[0-9]:[0-9]}}], s[{{[0-9]:[0-9]}}], 0xb ; encoding: [0x0b
52 define amdgpu_kernel void @smrd3(i32 addrspace(4)* %ptr) {
54 %0 = getelementptr i32, i32 addrspace(4)* %ptr, i64 4294967296 ; 2 ^ 32
55 %1 = load i32, i32 addrspace(4)* %0
56 store i32 %1, i32 addrspace(1)* undef
60 ; SMRD load with the largest possible immediate offset on VI
61 ; GCN-LABEL: {{^}}smrd4:
62 ; SI: s_mov_b32 [[OFFSET:s[0-9]+]], 0xffffc
63 ; SI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], [[OFFSET]]
64 ; CI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x3ffff
65 ; VI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0xffffc
66 define amdgpu_kernel void @smrd4(i32 addrspace(4)* %ptr) {
68 %0 = getelementptr i32, i32 addrspace(4)* %ptr, i64 262143
69 %1 = load i32, i32 addrspace(4)* %0
70 store i32 %1, i32 addrspace(1)* undef
74 ; SMRD load with an offset greater than the largest possible immediate on VI
75 ; GCN-LABEL: {{^}}smrd5:
76 ; SIVI: s_mov_b32 [[OFFSET:s[0-9]+]], 0x100000
77 ; SIVI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], [[OFFSET]]
78 ; CI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x40000
80 define amdgpu_kernel void @smrd5(i32 addrspace(4)* %ptr) {
82 %0 = getelementptr i32, i32 addrspace(4)* %ptr, i64 262144
83 %1 = load i32, i32 addrspace(4)* %0
84 store i32 %1, i32 addrspace(1)* undef