xref: /aosp_15_r20/external/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.buffer.load.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker;RUN: llc < %s -march=amdgcn -mcpu=verde -verify-machineinstrs | FileCheck %s -check-prefix=CHECK -check-prefix=SICI
2*9880d681SAndroid Build Coastguard Worker;RUN: llc < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs | FileCheck %s -check-prefix=CHECK -check-prefix=VI
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load:
5*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[0:3], off, s[0:3], 0
6*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[4:7], off, s[0:3], 0 glc
7*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[8:11], off, s[0:3], 0 slc
8*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
9*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps {<4 x float>, <4 x float>, <4 x float>} @buffer_load(<4 x i32> inreg) {
10*9880d681SAndroid Build Coastguard Workermain_body:
11*9880d681SAndroid Build Coastguard Worker  %data = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 0, i32 0, i1 0, i1 0)
12*9880d681SAndroid Build Coastguard Worker  %data_glc = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 0, i32 0, i1 1, i1 0)
13*9880d681SAndroid Build Coastguard Worker  %data_slc = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 0, i32 0, i1 0, i1 1)
14*9880d681SAndroid Build Coastguard Worker  %r0 = insertvalue {<4 x float>, <4 x float>, <4 x float>} undef, <4 x float> %data, 0
15*9880d681SAndroid Build Coastguard Worker  %r1 = insertvalue {<4 x float>, <4 x float>, <4 x float>} %r0, <4 x float> %data_glc, 1
16*9880d681SAndroid Build Coastguard Worker  %r2 = insertvalue {<4 x float>, <4 x float>, <4 x float>} %r1, <4 x float> %data_slc, 2
17*9880d681SAndroid Build Coastguard Worker  ret {<4 x float>, <4 x float>, <4 x float>} %r2
18*9880d681SAndroid Build Coastguard Worker}
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_immoffs:
21*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[0:3], off, s[0:3], 0 offset:42
22*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
23*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps <4 x float> @buffer_load_immoffs(<4 x i32> inreg) {
24*9880d681SAndroid Build Coastguard Workermain_body:
25*9880d681SAndroid Build Coastguard Worker  %data = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 0, i32 42, i1 0, i1 0)
26*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %data
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_immoffs_large:
30*9880d681SAndroid Build Coastguard Worker;SICI: buffer_load_dwordx4 v[0:3], {{v[0-9]+}}, s[0:3], 0 offen
31*9880d681SAndroid Build Coastguard Worker;VI: s_movk_i32 [[OFFSET:s[0-9]+]], 0x1fff
32*9880d681SAndroid Build Coastguard Worker;VI: buffer_load_dwordx4 v[0:3], off, s[0:3], [[OFFSET]] offset:1
33*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
34*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps <4 x float> @buffer_load_immoffs_large(<4 x i32> inreg) {
35*9880d681SAndroid Build Coastguard Workermain_body:
36*9880d681SAndroid Build Coastguard Worker  %data = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 0, i32 8192, i1 0, i1 0)
37*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %data
38*9880d681SAndroid Build Coastguard Worker}
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_idx:
41*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[0:3], v0, s[0:3], 0 idxen
42*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
43*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps <4 x float> @buffer_load_idx(<4 x i32> inreg, i32) {
44*9880d681SAndroid Build Coastguard Workermain_body:
45*9880d681SAndroid Build Coastguard Worker  %data = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 %1, i32 0, i1 0, i1 0)
46*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %data
47*9880d681SAndroid Build Coastguard Worker}
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_ofs:
50*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[0:3], v0, s[0:3], 0 offen
51*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
52*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps <4 x float> @buffer_load_ofs(<4 x i32> inreg, i32) {
53*9880d681SAndroid Build Coastguard Workermain_body:
54*9880d681SAndroid Build Coastguard Worker  %data = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 0, i32 %1, i1 0, i1 0)
55*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %data
56*9880d681SAndroid Build Coastguard Worker}
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_ofs_imm:
59*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[0:3], v0, s[0:3], 0 offen offset:58
60*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
61*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps <4 x float> @buffer_load_ofs_imm(<4 x i32> inreg, i32) {
62*9880d681SAndroid Build Coastguard Workermain_body:
63*9880d681SAndroid Build Coastguard Worker  %ofs = add i32 %1, 58
64*9880d681SAndroid Build Coastguard Worker  %data = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 0, i32 %ofs, i1 0, i1 0)
65*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %data
66*9880d681SAndroid Build Coastguard Worker}
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_both:
69*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[0:3], v[0:1], s[0:3], 0 idxen offen
70*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
71*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps <4 x float> @buffer_load_both(<4 x i32> inreg, i32, i32) {
72*9880d681SAndroid Build Coastguard Workermain_body:
73*9880d681SAndroid Build Coastguard Worker  %data = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 %1, i32 %2, i1 0, i1 0)
74*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %data
75*9880d681SAndroid Build Coastguard Worker}
76*9880d681SAndroid Build Coastguard Worker
77*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_both_reversed:
78*9880d681SAndroid Build Coastguard Worker;CHECK: v_mov_b32_e32 v2, v0
79*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[0:3], v[1:2], s[0:3], 0 idxen offen
80*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
81*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps <4 x float> @buffer_load_both_reversed(<4 x i32> inreg, i32, i32) {
82*9880d681SAndroid Build Coastguard Workermain_body:
83*9880d681SAndroid Build Coastguard Worker  %data = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 %2, i32 %1, i1 0, i1 0)
84*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %data
85*9880d681SAndroid Build Coastguard Worker}
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_x1:
88*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dword v0, v[0:1], s[0:3], 0 idxen offen
89*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
90*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps float @buffer_load_x1(<4 x i32> inreg %rsrc, i32 %idx, i32 %ofs) {
91*9880d681SAndroid Build Coastguard Workermain_body:
92*9880d681SAndroid Build Coastguard Worker  %data = call float @llvm.amdgcn.buffer.load.f32(<4 x i32> %rsrc, i32 %idx, i32 %ofs, i1 0, i1 0)
93*9880d681SAndroid Build Coastguard Worker  ret float %data
94*9880d681SAndroid Build Coastguard Worker}
95*9880d681SAndroid Build Coastguard Worker
96*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_x2:
97*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx2 v[0:1], v[0:1], s[0:3], 0 idxen offen
98*9880d681SAndroid Build Coastguard Worker;CHECK: s_waitcnt
99*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps <2 x float> @buffer_load_x2(<4 x i32> inreg %rsrc, i32 %idx, i32 %ofs) {
100*9880d681SAndroid Build Coastguard Workermain_body:
101*9880d681SAndroid Build Coastguard Worker  %data = call <2 x float> @llvm.amdgcn.buffer.load.v2f32(<4 x i32> %rsrc, i32 %idx, i32 %ofs, i1 0, i1 0)
102*9880d681SAndroid Build Coastguard Worker  ret <2 x float> %data
103*9880d681SAndroid Build Coastguard Worker}
104*9880d681SAndroid Build Coastguard Worker
105*9880d681SAndroid Build Coastguard Worker;CHECK-LABEL: {{^}}buffer_load_negative_offset:
106*9880d681SAndroid Build Coastguard Worker;CHECK: v_add_i32_e32 [[VOFS:v[0-9]+]], vcc, -16, v0
107*9880d681SAndroid Build Coastguard Worker;CHECK: buffer_load_dwordx4 v[0:3], [[VOFS]], s[0:3], 0 offen
108*9880d681SAndroid Build Coastguard Workerdefine amdgpu_ps <4 x float> @buffer_load_negative_offset(<4 x i32> inreg, i32 %ofs) {
109*9880d681SAndroid Build Coastguard Workermain_body:
110*9880d681SAndroid Build Coastguard Worker  %ofs.1 = add i32 %ofs, -16
111*9880d681SAndroid Build Coastguard Worker  %data = call <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32> %0, i32 0, i32 %ofs.1, i1 0, i1 0)
112*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %data
113*9880d681SAndroid Build Coastguard Worker}
114*9880d681SAndroid Build Coastguard Worker
115*9880d681SAndroid Build Coastguard Workerdeclare float @llvm.amdgcn.buffer.load.f32(<4 x i32>, i32, i32, i1, i1) #0
116*9880d681SAndroid Build Coastguard Workerdeclare <2 x float> @llvm.amdgcn.buffer.load.v2f32(<4 x i32>, i32, i32, i1, i1) #0
117*9880d681SAndroid Build Coastguard Workerdeclare <4 x float> @llvm.amdgcn.buffer.load.v4f32(<4 x i32>, i32, i32, i1, i1) #0
118*9880d681SAndroid Build Coastguard Worker
119*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind readonly }
120