1 ;RUN: llc < %s -mtriple=amdgcn -mcpu=verde -verify-machineinstrs | FileCheck %s
2 ;RUN: llc < %s -mtriple=amdgcn -mcpu=tonga -verify-machineinstrs | FileCheck %s
4 ;CHECK-LABEL: {{^}}buffer_load:
5 ;CHECK: buffer_load_format_xyzw v[0:3], off, s[0:3], 0
6 ;CHECK: buffer_load_format_xyzw v[4:7], off, s[0:3], 0 glc
7 ;CHECK: buffer_load_format_xyzw v[8:11], off, s[0:3], 0 slc
9 define amdgpu_ps {<4 x float>, <4 x float>, <4 x float>} @buffer_load(<4 x i32> inreg) {
11 %data = call <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32> %0, i32 0, i32 0, i32 0)
12 %data_glc = call <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32> %0, i32 0, i32 0, i32 1)
13 %data_slc = call <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32> %0, i32 0, i32 0, i32 2)
14 %r0 = insertvalue {<4 x float>, <4 x float>, <4 x float>} undef, <4 x float> %data, 0
15 %r1 = insertvalue {<4 x float>, <4 x float>, <4 x float>} %r0, <4 x float> %data_glc, 1
16 %r2 = insertvalue {<4 x float>, <4 x float>, <4 x float>} %r1, <4 x float> %data_slc, 2
17 ret {<4 x float>, <4 x float>, <4 x float>} %r2
20 ;CHECK-LABEL: {{^}}buffer_load_v4i32:
21 ;CHECK: buffer_load_format_xyzw v[0:3], off, s[0:3], 0
22 ;CHECK: buffer_load_format_xyzw v[4:7], off, s[0:3], 0 glc
23 ;CHECK: buffer_load_format_xyzw v[8:11], off, s[0:3], 0 slc
25 define amdgpu_ps {<4 x float>, <4 x float>, <4 x float>} @buffer_load_v4i32(<4 x i32> inreg) {
27 %data = call <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32> %0, i32 0, i32 0, i32 0)
28 %data_glc = call <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32> %0, i32 0, i32 0, i32 1)
29 %data_slc = call <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32> %0, i32 0, i32 0, i32 2)
30 %fdata = bitcast <4 x i32> %data to <4 x float>
31 %fdata_glc = bitcast <4 x i32> %data_glc to <4 x float>
32 %fdata_slc = bitcast <4 x i32> %data_slc to <4 x float>
33 %r0 = insertvalue {<4 x float>, <4 x float>, <4 x float>} undef, <4 x float> %fdata, 0
34 %r1 = insertvalue {<4 x float>, <4 x float>, <4 x float>} %r0, <4 x float> %fdata_glc, 1
35 %r2 = insertvalue {<4 x float>, <4 x float>, <4 x float>} %r1, <4 x float> %fdata_slc, 2
36 ret {<4 x float>, <4 x float>, <4 x float>} %r2
39 ;CHECK-LABEL: {{^}}buffer_load_immoffs:
40 ;CHECK: buffer_load_format_xyzw v[0:3], off, s[0:3], 0 offset:42
42 define amdgpu_ps <4 x float> @buffer_load_immoffs(<4 x i32> inreg) {
44 %data = call <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32> %0, i32 42, i32 0, i32 0)
48 ;CHECK-LABEL: {{^}}buffer_load_immoffs_v4i32:
49 ;CHECK: buffer_load_format_xyzw v[0:3], off, s[0:3], 0 offset:42
51 define amdgpu_ps <4 x float> @buffer_load_immoffs_v4i32(<4 x i32> inreg) {
53 %data = call <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32> %0, i32 42, i32 0, i32 0)
54 %fdata = bitcast <4 x i32> %data to <4 x float>
55 ret <4 x float> %fdata
58 ;CHECK-LABEL: {{^}}buffer_load_immoffs_large:
59 ;CHECK-DAG: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, off, s[0:3], 60 offset:4092
60 ;CHECK-DAG: s_movk_i32 [[OFS1:s[0-9]+]], 0x7ffc
61 ;CHECK-DAG: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, off, s[0:3], [[OFS1]] offset:4092
62 ;CHECK-DAG: s_mov_b32 [[OFS2:s[0-9]+]], 0x8ffc
63 ;CHECK-DAG: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, off, s[0:3], [[OFS2]] offset:4
65 define amdgpu_ps <4 x float> @buffer_load_immoffs_large(<4 x i32> inreg) {
67 %d.0 = call <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32> %0, i32 4092, i32 60, i32 0)
68 %d.1 = call <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32> %0, i32 4092, i32 32764, i32 0)
69 %d.2 = call <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32> %0, i32 4, i32 36860, i32 0)
70 %d.3 = fadd <4 x float> %d.0, %d.1
71 %data = fadd <4 x float> %d.2, %d.3
75 ;CHECK-LABEL: {{^}}buffer_load_immoffs_large_v4i32:
76 ;CHECK-DAG: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, off, s[0:3], 60 offset:4092
77 ;CHECK-DAG: s_movk_i32 [[OFS1:s[0-9]+]], 0x7ffc
78 ;CHECK-DAG: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, off, s[0:3], [[OFS1]] offset:4092
79 ;CHECK-DAG: s_mov_b32 [[OFS2:s[0-9]+]], 0x8ffc
80 ;CHECK-DAG: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, off, s[0:3], [[OFS2]] offset:4
82 define amdgpu_ps <4 x float> @buffer_load_immoffs_large_v4i32(<4 x i32> inreg) {
84 %d.0 = call <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32> %0, i32 4092, i32 60, i32 0)
85 %d.1 = call <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32> %0, i32 4092, i32 32764, i32 0)
86 %d.2 = call <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32> %0, i32 4, i32 36860, i32 0)
87 %fd.0 = bitcast <4 x i32> %d.0 to <4 x float>
88 %fd.1 = bitcast <4 x i32> %d.1 to <4 x float>
89 %fd.2 = bitcast <4 x i32> %d.2 to <4 x float>
90 %d.3 = fadd <4 x float> %fd.0, %fd.1
91 %data = fadd <4 x float> %fd.2, %d.3
95 ;CHECK-LABEL: {{^}}buffer_load_ofs:
96 ;CHECK: buffer_load_format_xyzw v[0:3], v0, s[0:3], 0 offen
98 define amdgpu_ps <4 x float> @buffer_load_ofs(<4 x i32> inreg, i32) {
100 %data = call <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32> %0, i32 %1, i32 0, i32 0)
101 ret <4 x float> %data
104 ;CHECK-LABEL: {{^}}buffer_load_ofs_v4i32:
105 ;CHECK: buffer_load_format_xyzw v[0:3], v0, s[0:3], 0 offen
107 define amdgpu_ps <4 x float> @buffer_load_ofs_v4i32(<4 x i32> inreg, i32) {
109 %data = call <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32> %0, i32 %1, i32 0, i32 0)
110 %fdata = bitcast <4 x i32> %data to <4 x float>
111 ret <4 x float> %fdata
114 ;CHECK-LABEL: {{^}}buffer_load_ofs_imm:
115 ;CHECK: buffer_load_format_xyzw v[0:3], v0, s[0:3], 0 offen offset:60
117 define amdgpu_ps <4 x float> @buffer_load_ofs_imm(<4 x i32> inreg, i32) {
119 %ofs = add i32 %1, 60
120 %data = call <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32> %0, i32 %ofs, i32 0, i32 0)
121 ret <4 x float> %data
124 ;CHECK-LABEL: {{^}}buffer_load_ofs_imm_v4i32:
125 ;CHECK: buffer_load_format_xyzw v[0:3], v0, s[0:3], 0 offen offset:60
127 define amdgpu_ps <4 x float> @buffer_load_ofs_imm_v4i32(<4 x i32> inreg, i32) {
129 %ofs = add i32 %1, 60
130 %data = call <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32> %0, i32 %ofs, i32 0, i32 0)
131 %fdata = bitcast <4 x i32> %data to <4 x float>
132 ret <4 x float> %fdata
135 ;CHECK-LABEL: {{^}}buffer_load_x:
136 ;CHECK: buffer_load_format_x v0, off, s[0:3], 0
138 define amdgpu_ps float @buffer_load_x(<4 x i32> inreg %rsrc) {
140 %data = call float @llvm.amdgcn.raw.buffer.load.format.f32(<4 x i32> %rsrc, i32 0, i32 0, i32 0)
144 ;CHECK-LABEL: {{^}}buffer_load_xy:
145 ;CHECK: buffer_load_format_xy v[0:1], off, s[0:3], 0
147 define amdgpu_ps <2 x float> @buffer_load_xy(<4 x i32> inreg %rsrc) {
149 %data = call <2 x float> @llvm.amdgcn.raw.buffer.load.format.v2f32(<4 x i32> %rsrc, i32 0, i32 0, i32 0)
150 ret <2 x float> %data
153 declare float @llvm.amdgcn.raw.buffer.load.format.f32(<4 x i32>, i32, i32, i32) #0
154 declare <2 x float> @llvm.amdgcn.raw.buffer.load.format.v2f32(<4 x i32>, i32, i32, i32) #0
155 declare <4 x float> @llvm.amdgcn.raw.buffer.load.format.v4f32(<4 x i32>, i32, i32, i32) #0
156 declare <4 x i32> @llvm.amdgcn.raw.buffer.load.format.v4i32(<4 x i32>, i32, i32, i32) #0
158 attributes #0 = { nounwind readonly }