1 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs -show-mc-encoding < %s | FileCheck --check-prefixes=SI,GCN,SICIVI,SICI,SIVIGFX9_10 %s
2 ; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs -show-mc-encoding < %s | FileCheck --check-prefixes=CI,GCN,SICIVI,SICI %s
3 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs -show-mc-encoding < %s | FileCheck --check-prefixes=VI,GCN,SICIVI,VIGFX9_10,SIVIGFX9_10 %s
4 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs -show-mc-encoding < %s | FileCheck --check-prefixes=GFX9_10,GCN,VIGFX9_10,SIVIGFX9_10 %s
5 ; RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs -show-mc-encoding < %s | FileCheck --check-prefixes=GFX10,GFX9_10,GCN,VIGFX9_10,SIVIGFX9_10 %s
7 ; SMRD load with an immediate offset.
8 ; GCN-LABEL: {{^}}smrd0:
9 ; SICI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x1 ; encoding: [0x01
10 ; VIGFX9_10: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x4
11 define amdgpu_kernel void @smrd0(ptr addrspace(1) %out, ptr addrspace(4) %ptr) #0 {
13 %tmp = getelementptr i32, ptr addrspace(4) %ptr, i64 1
14 %tmp1 = load i32, ptr addrspace(4) %tmp
15 store i32 %tmp1, ptr addrspace(1) %out
19 ; SMRD load with the largest possible immediate offset.
20 ; GCN-LABEL: {{^}}smrd1:
21 ; SICI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0xff ; encoding: [0xff,0x{{[0-9]+[137]}}
22 ; VIGFX9_10: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x3fc
23 define amdgpu_kernel void @smrd1(ptr addrspace(1) %out, ptr addrspace(4) %ptr) #0 {
25 %tmp = getelementptr i32, ptr addrspace(4) %ptr, i64 255
26 %tmp1 = load i32, ptr addrspace(4) %tmp
27 store i32 %tmp1, ptr addrspace(1) %out
31 ; SMRD load with an offset greater than the largest possible immediate.
32 ; GCN-LABEL: {{^}}smrd2:
33 ; SI: s_movk_i32 s[[OFFSET:[0-9]]], 0x400
34 ; SI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], s[[OFFSET]] ; encoding: [0x0[[OFFSET]]
35 ; CI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x100
36 ; VIGFX9_10: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x400
38 define amdgpu_kernel void @smrd2(ptr addrspace(1) %out, ptr addrspace(4) %ptr) #0 {
40 %tmp = getelementptr i32, ptr addrspace(4) %ptr, i64 256
41 %tmp1 = load i32, ptr addrspace(4) %tmp
42 store i32 %tmp1, ptr addrspace(1) %out
46 ; SMRD load with a 64-bit offset
47 ; GCN-LABEL: {{^}}smrd3:
48 ; FIXME: There are too many copies here because we don't fold immediates
49 ; through REG_SEQUENCE
50 ; SI: s_load_dwordx2 s[{{[0-9]:[0-9]}}], s[{{[0-9]:[0-9]}}], 0x13 ; encoding: [0x13
53 define amdgpu_kernel void @smrd3(ptr addrspace(1) %out, [8 x i32], ptr addrspace(4) %ptr) #0 {
55 %tmp = getelementptr i32, ptr addrspace(4) %ptr, i64 4294967296
56 %tmp1 = load i32, ptr addrspace(4) %tmp
57 store i32 %tmp1, ptr addrspace(1) %out
61 ; SMRD load with the largest possible immediate offset on VI
62 ; GCN-LABEL: {{^}}smrd4:
63 ; SI: s_mov_b32 [[OFFSET:s[0-9]+]], 0xffffc
64 ; SI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], [[OFFSET]]
65 ; CI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x3ffff
66 ; VI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0xffffc
67 ; GFX9_10: s_mov_b32 [[OFFSET:s[0-9]+]], 0xffffc
68 ; GFX9_10: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], [[OFFSET]]
69 define amdgpu_kernel void @smrd4(ptr addrspace(1) %out, ptr addrspace(4) %ptr) #0 {
71 %tmp = getelementptr i32, ptr addrspace(4) %ptr, i64 262143
72 %tmp1 = load i32, ptr addrspace(4) %tmp
73 store i32 %tmp1, ptr addrspace(1) %out
77 ; SMRD load with an offset greater than the largest possible immediate on VI
78 ; GCN-LABEL: {{^}}smrd5:
79 ; SIVIGFX9_10: s_mov_b32 [[OFFSET:s[0-9]+]], 0x100000
80 ; SIVIGFX9_10: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], [[OFFSET]]
81 ; CI: s_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x40000
83 define amdgpu_kernel void @smrd5(ptr addrspace(1) %out, ptr addrspace(4) %ptr) #0 {
85 %tmp = getelementptr i32, ptr addrspace(4) %ptr, i64 262144
86 %tmp1 = load i32, ptr addrspace(4) %tmp
87 store i32 %tmp1, ptr addrspace(1) %out
91 ; GFX9_10 can use a signed immediate byte offset
92 ; GCN-LABEL: {{^}}smrd6:
93 ; SICIVI: s_add_u32 s{{[0-9]}}, s{{[0-9]}}, -4
94 ; SICIVI: s_load_dword s{{[0-9]}}, s{{\[[0-9]+:[0-9]+\]}}, 0x0
95 ; GFX9_10: s_load_dword s{{[0-9]}}, s{{\[[0-9]+:[0-9]+\]}}, -0x4
96 define amdgpu_kernel void @smrd6(ptr addrspace(1) %out, ptr addrspace(4) %ptr) #0 {
98 %tmp = getelementptr i32, ptr addrspace(4) %ptr, i64 -1
99 %tmp1 = load i32, ptr addrspace(4) %tmp
100 store i32 %tmp1, ptr addrspace(1) %out
104 ; Don't use a negative SGPR offset
105 ; GCN-LABEL: {{^}}smrd7:
106 ; GCN: s_add_u32 s{{[0-9]}}, s{{[0-9]}}, 0xffe00000
107 ; SICIVI: s_load_dword s{{[0-9]}}, s{{\[[0-9]+:[0-9]+\]}}, 0x0
108 ; GFX9_10: s_load_dword s{{[0-9]}}, s{{\[[0-9]+:[0-9]+\]}}, 0x0
109 define amdgpu_kernel void @smrd7(ptr addrspace(1) %out, ptr addrspace(4) %ptr) #0 {
111 %tmp = getelementptr i32, ptr addrspace(4) %ptr, i64 -524288
112 %tmp1 = load i32, ptr addrspace(4) %tmp
113 store i32 %tmp1, ptr addrspace(1) %out
117 ; GCN-LABEL: {{^}}smrd_hazard:
118 ; GCN-DAG: s_mov_b32 s3, 3
119 ; GCN-DAG: s_mov_b32 s2, 2
120 ; GCN-DAG: s_mov_b32 s1, 1
121 ; GCN-DAG: s_mov_b32 s0, 0
123 ; GCN-NEXT: s_buffer_load_dword s0, s[0:3], 0x0
124 define amdgpu_ps float @smrd_hazard(<4 x i32> inreg %desc) #0 {
126 %d0 = insertelement <4 x i32> undef, i32 0, i32 0
127 %d1 = insertelement <4 x i32> %d0, i32 1, i32 1
128 %d2 = insertelement <4 x i32> %d1, i32 2, i32 2
129 %d3 = insertelement <4 x i32> %d2, i32 3, i32 3
130 %r = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %d3, i32 0, i32 0)
134 ; SMRD load using the load.const.v4i32 intrinsic with an immediate offset
135 ; GCN-LABEL: {{^}}smrd_load_const0:
136 ; SICI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x4 ; encoding: [0x04
137 ; VIGFX9_10: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x10
138 define amdgpu_ps void @smrd_load_const0(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
140 %tmp20 = load <4 x i32>, ptr addrspace(4) %arg
141 %tmp21 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %tmp20, i32 16, i32 0)
142 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %tmp21, float %tmp21, float %tmp21, float %tmp21, i1 true, i1 true) #0
146 ; SMRD load using the load.const.v4i32 intrinsic with the largest possible immediate
148 ; GCN-LABEL: {{^}}smrd_load_const1:
149 ; SICI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0xff ; encoding: [0xff
150 ; SICI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0xff glc ; encoding: [0xff
151 ; VIGFX9_10: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]+}}], 0x3fc ;
152 ; VIGFX9_10: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]+}}], 0x3fc glc ;
153 define amdgpu_ps void @smrd_load_const1(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
155 %tmp20 = load <4 x i32>, ptr addrspace(4) %arg
156 %tmp21 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %tmp20, i32 1020, i32 0)
157 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
158 %s.buffer = call i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32> %tmp22, i32 1020, i32 1)
159 %s.buffer.float = bitcast i32 %s.buffer to float
160 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %tmp21, float %tmp21, float %tmp21, float %s.buffer.float, i1 true, i1 true) #0
164 ; SMRD load using the load.const.v4i32 intrinsic with an offset greater than the
165 ; largets possible immediate.
167 ; GCN-LABEL: {{^}}smrd_load_const2:
168 ; SI: s_movk_i32 s[[OFFSET:[0-9]]], 0x400
169 ; SI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], s[[OFFSET]] ; encoding: [0x0[[OFFSET]]
170 ; SI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], s[[OFFSET]] ; encoding: [0x0[[OFFSET]]
171 ; CI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x100
172 ; CI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x100
173 ; VIGFX9_10: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]+}}], 0x400
174 ; VIGFX9_10: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]+}}], 0x400
175 define amdgpu_ps void @smrd_load_const2(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
177 %tmp20 = load <4 x i32>, ptr addrspace(4) %arg
178 %tmp21 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %tmp20, i32 1024, i32 0)
179 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
180 %s.buffer = call i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32> %tmp22, i32 1024, i32 0)
181 %s.buffer.float = bitcast i32 %s.buffer to float
182 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %tmp21, float %tmp21, float %tmp21, float %s.buffer.float, i1 true, i1 true) #0
186 ; SMRD load with the largest possible immediate offset on VI
187 ; GCN-LABEL: {{^}}smrd_load_const3:
188 ; SI: s_mov_b32 [[OFFSET:s[0-9]+]], 0xffffc
189 ; SI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], [[OFFSET]]
190 ; SI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], [[OFFSET]]
191 ; CI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x3ffff
192 ; CI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x3ffff
193 ; VIGFX9_10: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]+}}], 0xffffc
194 ; VIGFX9_10: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]+}}], 0xffffc
195 define amdgpu_ps void @smrd_load_const3(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
197 %tmp20 = load <4 x i32>, ptr addrspace(4) %arg
198 %tmp21 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %tmp20, i32 1048572, i32 0)
199 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
200 %s.buffer = call i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32> %tmp22, i32 1048572, i32 0)
201 %s.buffer.float = bitcast i32 %s.buffer to float
202 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %tmp21, float %tmp21, float %tmp21, float %s.buffer.float, i1 true, i1 true) #0
206 ; SMRD load with an offset greater than the largest possible immediate on VI
207 ; GCN-LABEL: {{^}}smrd_load_const4:
208 ; SIVIGFX9_10: s_mov_b32 [[OFFSET:s[0-9]+]], 0x100000
209 ; SIVIGFX9_10: s_buffer_load_dword s{{[0-9]+}}, s[{{[0-9]:[0-9]+}}], [[OFFSET]]
210 ; SIVIGFX9_10: s_buffer_load_dword s{{[0-9]+}}, s[{{[0-9]:[0-9]+}}], [[OFFSET]]
211 ; CI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x40000
212 ; CI: s_buffer_load_dword s{{[0-9]}}, s[{{[0-9]:[0-9]}}], 0x40000
214 define amdgpu_ps void @smrd_load_const4(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
216 %tmp20 = load <4 x i32>, ptr addrspace(4) %arg
217 %tmp21 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %tmp20, i32 1048576, i32 0)
218 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
219 %s.buffer = call i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32> %tmp22, i32 1048576, i32 0)
220 %s.buffer.float = bitcast i32 %s.buffer to float
221 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %tmp21, float %tmp21, float %tmp21, float %s.buffer.float, i1 true, i1 true) #0
225 ; dwordx2 s.buffer.load
226 ; GCN-LABEL: {{^}}s_buffer_load_dwordx2:
227 ; VIGFX9_10: s_buffer_load_dwordx2 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x80
228 ; SICI: s_buffer_load_dwordx2 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x20
229 define amdgpu_ps void @s_buffer_load_dwordx2(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
231 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
232 %s.buffer = call <2 x i32> @llvm.amdgcn.s.buffer.load.v2i32(<4 x i32> %tmp22, i32 128, i32 0)
233 %s.buffer.0 = extractelement <2 x i32> %s.buffer, i32 0
234 %s.buffer.0.float = bitcast i32 %s.buffer.0 to float
235 %s.buffer.1 = extractelement <2 x i32> %s.buffer, i32 1
236 %s.buffer.1.float = bitcast i32 %s.buffer.1 to float
237 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %s.buffer.0.float, float %s.buffer.1.float, float %s.buffer.0.float, float %s.buffer.1.float, i1 true, i1 true) #0
241 ; dwordx4 s.buffer.load
242 ; GCN-LABEL: {{^}}s_buffer_load_dwordx4:
243 ; VIGFX9_10: s_buffer_load_dwordx4 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x80
244 ; SICI: s_buffer_load_dwordx4 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x20
245 define amdgpu_ps void @s_buffer_load_dwordx4(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
247 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
248 %s.buffer = call <4 x i32> @llvm.amdgcn.s.buffer.load.v4i32(<4 x i32> %tmp22, i32 128, i32 0)
249 %s.buffer.0 = extractelement <4 x i32> %s.buffer, i32 0
250 %s.buffer.0.float = bitcast i32 %s.buffer.0 to float
251 %s.buffer.1 = extractelement <4 x i32> %s.buffer, i32 1
252 %s.buffer.1.float = bitcast i32 %s.buffer.1 to float
253 %s.buffer.2 = extractelement <4 x i32> %s.buffer, i32 2
254 %s.buffer.2.float = bitcast i32 %s.buffer.2 to float
255 %s.buffer.3 = extractelement <4 x i32> %s.buffer, i32 3
256 %s.buffer.3.float = bitcast i32 %s.buffer.3 to float
257 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %s.buffer.0.float, float %s.buffer.1.float, float %s.buffer.2.float, float %s.buffer.3.float, i1 true, i1 true) #0
261 ; dwordx8 s.buffer.load
262 ; GCN-LABEL: {{^}}s_buffer_load_dwordx8:
263 ; VIGFX9_10: s_buffer_load_dwordx8 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x80
264 ; SICI: s_buffer_load_dwordx8 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x20
265 define amdgpu_ps void @s_buffer_load_dwordx8(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
267 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
268 %s.buffer = call <8 x i32> @llvm.amdgcn.s.buffer.load.v8i32(<4 x i32> %tmp22, i32 128, i32 0)
269 %s.buffer.0 = extractelement <8 x i32> %s.buffer, i32 0
270 %s.buffer.0.float = bitcast i32 %s.buffer.0 to float
271 %s.buffer.1 = extractelement <8 x i32> %s.buffer, i32 2
272 %s.buffer.1.float = bitcast i32 %s.buffer.1 to float
273 %s.buffer.2 = extractelement <8 x i32> %s.buffer, i32 5
274 %s.buffer.2.float = bitcast i32 %s.buffer.2 to float
275 %s.buffer.3 = extractelement <8 x i32> %s.buffer, i32 7
276 %s.buffer.3.float = bitcast i32 %s.buffer.3 to float
277 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %s.buffer.0.float, float %s.buffer.1.float, float %s.buffer.2.float, float %s.buffer.3.float, i1 true, i1 true) #0
281 ; dwordx8 s.buffer.load
282 ; GCN-LABEL: {{^}}s_buffer_load_dwordx8_v8f32:
283 ; VIGFX9_10: s_buffer_load_dwordx8 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x80
284 ; SICI: s_buffer_load_dwordx8 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x20
285 define amdgpu_ps void @s_buffer_load_dwordx8_v8f32(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
287 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
288 %s.buffer = call <8 x float> @llvm.amdgcn.s.buffer.load.v8f32(<4 x i32> %tmp22, i32 128, i32 0)
289 %s.buffer.0 = extractelement <8 x float> %s.buffer, i32 0
290 %s.buffer.1 = extractelement <8 x float> %s.buffer, i32 2
291 %s.buffer.2 = extractelement <8 x float> %s.buffer, i32 5
292 %s.buffer.3 = extractelement <8 x float> %s.buffer, i32 7
293 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %s.buffer.0, float %s.buffer.1, float %s.buffer.2, float %s.buffer.3, i1 true, i1 true) #0
297 ; dwordx16 s.buffer.load
298 ; GCN-LABEL: {{^}}s_buffer_load_dwordx16:
299 ; VIGFX9_10: s_buffer_load_dwordx16 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x80
300 ; SICI: s_buffer_load_dwordx16 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x20
301 define amdgpu_ps void @s_buffer_load_dwordx16(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
303 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
304 %s.buffer = call <16 x i32> @llvm.amdgcn.s.buffer.load.v16i32(<4 x i32> %tmp22, i32 128, i32 0)
305 %s.buffer.0 = extractelement <16 x i32> %s.buffer, i32 0
306 %s.buffer.0.float = bitcast i32 %s.buffer.0 to float
307 %s.buffer.1 = extractelement <16 x i32> %s.buffer, i32 3
308 %s.buffer.1.float = bitcast i32 %s.buffer.1 to float
309 %s.buffer.2 = extractelement <16 x i32> %s.buffer, i32 12
310 %s.buffer.2.float = bitcast i32 %s.buffer.2 to float
311 %s.buffer.3 = extractelement <16 x i32> %s.buffer, i32 15
312 %s.buffer.3.float = bitcast i32 %s.buffer.3 to float
313 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %s.buffer.0.float, float %s.buffer.1.float, float %s.buffer.2.float, float %s.buffer.3.float, i1 true, i1 true) #0
317 ; GCN-LABEL: {{^}}s_buffer_load_dwordx16_v16f32:
318 ; VIGFX9_10: s_buffer_load_dwordx16 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x80
319 ; SICI: s_buffer_load_dwordx16 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]:[0-9]}}], 0x20
320 define amdgpu_ps void @s_buffer_load_dwordx16_v16f32(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in) #0 {
322 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
323 %s.buffer = call <16 x float> @llvm.amdgcn.s.buffer.load.v16f32(<4 x i32> %tmp22, i32 128, i32 0)
324 %s.buffer.0 = extractelement <16 x float> %s.buffer, i32 0
325 %s.buffer.1 = extractelement <16 x float> %s.buffer, i32 3
326 %s.buffer.2 = extractelement <16 x float> %s.buffer, i32 12
327 %s.buffer.3 = extractelement <16 x float> %s.buffer, i32 15
328 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %s.buffer.0, float %s.buffer.1, float %s.buffer.2, float %s.buffer.3, i1 true, i1 true) #0
332 ; GCN-LABEL: {{^}}smrd_sgpr_offset:
333 ; GCN: s_buffer_load_dword s{{[0-9]}}, s[0:3], s4
334 define amdgpu_ps float @smrd_sgpr_offset(<4 x i32> inreg %desc, i32 inreg %offset) #0 {
336 %r = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %offset, i32 0)
340 ; GCN-LABEL: {{^}}smrd_vgpr_offset:
341 ; GCN: buffer_load_dword v{{[0-9]}}, v0, s[0:3], 0 offen ;
342 define amdgpu_ps float @smrd_vgpr_offset(<4 x i32> inreg %desc, i32 %offset) #0 {
344 %r = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %offset, i32 0)
348 ; GCN-LABEL: {{^}}smrd_vgpr_offset_imm:
350 ; GCN-NEXT: buffer_load_dword v{{[0-9]}}, v0, s[0:3], 0 offen offset:4092 ;
351 define amdgpu_ps float @smrd_vgpr_offset_imm(<4 x i32> inreg %desc, i32 %offset) #0 {
353 %off = add i32 %offset, 4092
354 %r = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %off, i32 0)
358 ; GCN-LABEL: {{^}}smrd_vgpr_offset_imm_too_large:
360 ; SICI-NEXT: v_add_{{i|u}}32_e32 v0, {{(vcc, )?}}0x1000, v0
361 ; SICI-NEXT: buffer_load_dword v{{[0-9]}}, v0, s[0:3], 0 offen ;
362 ; VIGFX9_10-NEXT: buffer_load_dword v{{[0-9]}}, v0, s[0:3], 4 offen offset:4092 ;
363 define amdgpu_ps float @smrd_vgpr_offset_imm_too_large(<4 x i32> inreg %desc, i32 %offset) #0 {
365 %off = add i32 %offset, 4096
366 %r = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %off, i32 0)
370 ; GCN-LABEL: {{^}}smrd_imm_merged:
372 ; SICI-NEXT: s_buffer_load_dwordx4 s[{{[0-9]}}:{{[0-9]}}], s[0:3], 0x1
373 ; SICI-NEXT: s_buffer_load_dwordx2 s[{{[0-9]}}:{{[0-9]}}], s[0:3], 0x7
374 ; GFX10-NEXT: s_clause
375 ; VIGFX9_10-NEXT: s_buffer_load_dwordx4 s[{{[0-9]}}:{{[0-9]}}], s[0:3], 0x4
376 ; VIGFX9_10-NEXT: s_buffer_load_dwordx2 s[{{[0-9]}}:{{[0-9]}}], s[0:3], 0x1c
377 define amdgpu_ps void @smrd_imm_merged(<4 x i32> inreg %desc) #0 {
379 %r1 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 4, i32 0)
380 %r2 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 8, i32 0)
381 %r3 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 12, i32 0)
382 %r4 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 16, i32 0)
383 %r5 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 28, i32 0)
384 %r6 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 32, i32 0)
385 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %r1, float %r2, float %r3, float %r4, i1 true, i1 true) #0
386 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %r5, float %r6, float undef, float undef, i1 true, i1 true) #0
390 ; GCN-LABEL: {{^}}smrd_imm_merge_m0:
392 ; GCN: s_buffer_load_dwordx2
393 ; SICIVI: s_mov_b32 m0
394 ; SICIVI-DAG: v_interp_p1_f32
395 ; SICIVI-DAG: v_interp_p1_f32
396 ; SICIVI-DAG: v_interp_p1_f32
397 ; SICIVI-DAG: v_interp_p2_f32
398 ; SICIVI-DAG: v_interp_p2_f32
399 ; SICIVI-DAG: v_interp_p2_f32
401 ; extractelement does not result in movrels anymore for vectors gitting 8 dwords
402 ; SICIVI-NOT: s_mov_b32 m0
403 ; SICIVI-NOT: v_movrels_b32_e32
407 ; Merging is still thwarted on GFX9 due to s_set_gpr_idx
409 define amdgpu_ps float @smrd_imm_merge_m0(<4 x i32> inreg %desc, i32 inreg %prim, float %u, float %v) #0 {
411 %idx1.f = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 0, i32 0)
412 %idx1 = bitcast float %idx1.f to i32
414 %v0.x1 = call nsz float @llvm.amdgcn.interp.p1(float %u, i32 0, i32 0, i32 %prim)
415 %v0.x = call nsz float @llvm.amdgcn.interp.p2(float %v0.x1, float %v, i32 0, i32 0, i32 %prim)
416 %v0.y1 = call nsz float @llvm.amdgcn.interp.p1(float %u, i32 0, i32 1, i32 %prim)
417 %v0.y = call nsz float @llvm.amdgcn.interp.p2(float %v0.y1, float %v, i32 0, i32 1, i32 %prim)
418 %v0.z1 = call nsz float @llvm.amdgcn.interp.p1(float %u, i32 0, i32 2, i32 %prim)
419 %v0.z = call nsz float @llvm.amdgcn.interp.p2(float %v0.z1, float %v, i32 0, i32 2, i32 %prim)
420 %v0.tmp0 = insertelement <3 x float> undef, float %v0.x, i32 0
421 %v0.tmp1 = insertelement <3 x float> %v0.tmp0, float %v0.y, i32 1
422 %v0 = insertelement <3 x float> %v0.tmp1, float %v0.z, i32 2
423 %a = extractelement <3 x float> %v0, i32 %idx1
425 %v1.x1 = call nsz float @llvm.amdgcn.interp.p1(float %u, i32 1, i32 0, i32 %prim)
426 %v1.x = call nsz float @llvm.amdgcn.interp.p2(float %v1.x1, float %v, i32 1, i32 0, i32 %prim)
427 %v1.y1 = call nsz float @llvm.amdgcn.interp.p1(float %u, i32 1, i32 1, i32 %prim)
428 %v1.y = call nsz float @llvm.amdgcn.interp.p2(float %v1.y1, float %v, i32 1, i32 1, i32 %prim)
429 %v1.z1 = call nsz float @llvm.amdgcn.interp.p1(float %u, i32 1, i32 2, i32 %prim)
430 %v1.z = call nsz float @llvm.amdgcn.interp.p2(float %v1.z1, float %v, i32 1, i32 2, i32 %prim)
431 %v1.tmp0 = insertelement <3 x float> undef, float %v0.x, i32 0
432 %v1.tmp1 = insertelement <3 x float> %v0.tmp0, float %v0.y, i32 1
433 %v1 = insertelement <3 x float> %v0.tmp1, float %v0.z, i32 2
435 %b = extractelement <3 x float> %v1, i32 %idx1
436 %c = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 4, i32 0)
438 %res.tmp = fadd float %a, %b
439 %res = fadd float %res.tmp, %c
443 ; GCN-LABEL: {{^}}smrd_vgpr_merged:
445 ; GFX10-NEXT: s_clause
446 ; GCN-NEXT: buffer_load_dwordx4 v[{{[0-9]}}:{{[0-9]}}], v0, s[0:3], 0 offen offset:4
447 ; GCN-NEXT: buffer_load_dwordx2 v[{{[0-9]}}:{{[0-9]}}], v0, s[0:3], 0 offen offset:28
448 define amdgpu_ps void @smrd_vgpr_merged(<4 x i32> inreg %desc, i32 %a) #0 {
456 %r1 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %a1, i32 0)
457 %r2 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %a2, i32 0)
458 %r3 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %a3, i32 0)
459 %r4 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %a4, i32 0)
460 %r5 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %a5, i32 0)
461 %r6 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %a6, i32 0)
462 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %r1, float %r2, float %r3, float %r4, i1 true, i1 true) #0
463 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %r5, float %r6, float undef, float undef, i1 true, i1 true) #0
467 ; GCN-LABEL: {{^}}smrd_sgpr_descriptor_promoted
468 ; GCN: v_readfirstlane
469 define amdgpu_cs void @smrd_sgpr_descriptor_promoted(ptr addrspace(4) inreg noalias dereferenceable(18446744073709551615), i32) #0 {
471 br label %.outer_loop_header
473 ret_block: ; preds = %.outer, %.label22, %main_body
477 br label %.inner_loop_header
479 .inner_loop_header: ; preds = %.inner_loop_body, %.outer_loop_header
480 %loopctr.1 = phi i32 [ 0, %.outer_loop_header ], [ %loopctr.2, %.inner_loop_body ]
481 %loopctr.2 = add i32 %loopctr.1, 1
482 %inner_br1 = icmp slt i32 %loopctr.2, 10
483 br i1 %inner_br1, label %.inner_loop_body, label %ret_block
486 %descriptor = load <4 x i32>, ptr addrspace(4) %0, align 16, !invariant.load !0
487 %load1result = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %descriptor, i32 0, i32 0)
488 store float %load1result, ptr addrspace(1) undef
489 %inner_br2 = icmp uge i32 %1, 10
490 br i1 %inner_br2, label %.inner_loop_header, label %.outer_loop_body
493 %offset = shl i32 %loopctr.2, 6
494 %load2result = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %descriptor, i32 %offset, i32 0)
495 %outer_br = fcmp ueq float %load2result, 0x0
496 br i1 %outer_br, label %.outer_loop_header, label %ret_block
499 ; SMRD load with a non-const offset
500 ; GCN-LABEL: {{^}}smrd_load_nonconst0:
501 ; SIVIGFX9_10: s_buffer_load_dword s{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}}
502 ; SIVIGFX9_10: s_buffer_load_dword s{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}}
503 ; CI: s_buffer_load_dword s{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}}
504 ; CI: s_buffer_load_dword s{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}}
506 define amdgpu_ps void @smrd_load_nonconst0(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in, i32 inreg %ncoff) #0 {
508 %tmp20 = load <4 x i32>, ptr addrspace(4) %arg
509 %tmp21 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %tmp20, i32 %ncoff, i32 0)
510 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
511 %s.buffer = call i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32> %tmp22, i32 %ncoff, i32 0)
512 %s.buffer.float = bitcast i32 %s.buffer to float
513 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %tmp21, float %tmp21, float %tmp21, float %s.buffer.float, i1 true, i1 true) #0
517 ; SMRD load with a non-const non-uniform offset
518 ; GCN-LABEL: {{^}}smrd_load_nonconst1:
519 ; SIVIGFX9_10: buffer_load_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], 0 offen
520 ; SIVIGFX9_10: buffer_load_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], 0 offen
521 ; CI: buffer_load_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], 0 offen
522 ; CI: buffer_load_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], 0 offen
524 define amdgpu_ps void @smrd_load_nonconst1(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in, i32 %ncoff) #0 {
526 %tmp20 = load <4 x i32>, ptr addrspace(4) %arg
527 %tmp21 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %tmp20, i32 %ncoff, i32 0)
528 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
529 %s.buffer = call i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32> %tmp22, i32 %ncoff, i32 0)
530 %s.buffer.float = bitcast i32 %s.buffer to float
531 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %tmp21, float %tmp21, float %tmp21, float %s.buffer.float, i1 true, i1 true) #0
535 ; SMRD load with a non-const non-uniform offset of > 4 dwords (requires splitting)
536 ; GCN-LABEL: {{^}}smrd_load_nonconst2:
537 ; SIVIGFX9_10-DAG: buffer_load_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], 0 offen
538 ; SIVIGFX9_10-DAG: buffer_load_dwordx4 v[{{[0-9]+:[0-9]+}}], v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], 0 offen
539 ; CI: buffer_load_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], 0 offen
540 ; CI: buffer_load_dwordx4 v[{{[0-9]+:[0-9]+}}], v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], 0 offen
542 define amdgpu_ps void @smrd_load_nonconst2(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in, i32 %ncoff) #0 {
544 %tmp20 = load <4 x i32>, ptr addrspace(4) %arg
545 %tmp21 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %tmp20, i32 %ncoff, i32 0)
546 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
547 %s.buffer = call <8 x i32> @llvm.amdgcn.s.buffer.load.v8i32(<4 x i32> %tmp22, i32 %ncoff, i32 0)
548 %s.buffer.elt = extractelement <8 x i32> %s.buffer, i32 1
549 %s.buffer.float = bitcast i32 %s.buffer.elt to float
550 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %tmp21, float %tmp21, float %tmp21, float %s.buffer.float, i1 true, i1 true) #0
554 ; SMRD load with a non-const non-uniform offset of > 4 dwords (requires splitting)
555 ; GCN-LABEL: {{^}}smrd_load_nonconst3:
556 ; GCN-DAG: buffer_load_dwordx4 v[0:3], v{{[0-9]+}}, s[0:3], 0 offen ;
557 ; GCN-DAG: buffer_load_dwordx4 v[4:7], v{{[0-9]+}}, s[0:3], 0 offen offset:16 ;
558 ; GCN-DAG: buffer_load_dwordx4 v[8:11], v{{[0-9]+}}, s[0:3], 0 offen offset:32 ;
559 ; GCN-DAG: buffer_load_dwordx4 v[12:15], v{{[0-9]+}}, s[0:3], 0 offen offset:48 ;
560 ; GCN: ; return to shader part epilog
561 define amdgpu_ps <16 x float> @smrd_load_nonconst3(<4 x i32> inreg %rsrc, i32 %off) #0 {
563 %ld = call <16 x i32> @llvm.amdgcn.s.buffer.load.v16i32(<4 x i32> %rsrc, i32 %off, i32 0)
564 %bc = bitcast <16 x i32> %ld to <16 x float>
568 ; GCN-LABEL: {{^}}smrd_load_nonconst4:
569 ; SICI: v_add_i32_e32 v{{[0-9]+}}, vcc, 0xff8, v0 ;
570 ; SICI-DAG: buffer_load_dwordx4 v[0:3], v{{[0-9]+}}, s[0:3], 0 offen ;
571 ; SICI-DAG: buffer_load_dwordx4 v[4:7], v{{[0-9]+}}, s[0:3], 0 offen offset:16 ;
572 ; SICI-DAG: buffer_load_dwordx4 v[8:11], v{{[0-9]+}}, s[0:3], 0 offen offset:32 ;
573 ; SICI-DAG: buffer_load_dwordx4 v[12:15], v{{[0-9]+}}, s[0:3], 0 offen offset:48 ;
574 ; VIGFX9_10-DAG: buffer_load_dwordx4 v[0:3], v{{[0-9]+}}, s[0:3], 56 offen offset:4032 ;
575 ; VIGFX9_10-DAG: buffer_load_dwordx4 v[4:7], v{{[0-9]+}}, s[0:3], 56 offen offset:4048 ;
576 ; VIGFX9_10-DAG: buffer_load_dwordx4 v[8:11], v{{[0-9]+}}, s[0:3], 56 offen offset:4064 ;
577 ; VIGFX9_10-DAG: buffer_load_dwordx4 v[12:15], v{{[0-9]+}}, s[0:3], 56 offen offset:4080 ;
578 ; GCN: ; return to shader part epilog
579 define amdgpu_ps <16 x float> @smrd_load_nonconst4(<4 x i32> inreg %rsrc, i32 %off) #0 {
581 %off.2 = add i32 %off, 4088
582 %ld = call <16 x i32> @llvm.amdgcn.s.buffer.load.v16i32(<4 x i32> %rsrc, i32 %off.2, i32 0)
583 %bc = bitcast <16 x i32> %ld to <16 x float>
587 ; GCN-LABEL: {{^}}smrd_load_nonconst5:
588 ; SICI: v_add_i32_e32 v{{[0-9]+}}, vcc, 0x1004, v0
589 ; SICI-DAG: buffer_load_dwordx4 v[0:3], v{{[0-9]+}}, s[0:3], 0 offen ;
590 ; SICI-DAG: buffer_load_dwordx4 v[4:7], v{{[0-9]+}}, s[0:3], 0 offen offset:16 ;
591 ; SICI-DAG: buffer_load_dwordx4 v[8:11], v{{[0-9]+}}, s[0:3], 0 offen offset:32 ;
592 ; SICI-DAG: buffer_load_dwordx4 v[12:15], v{{[0-9]+}}, s[0:3], 0 offen offset:48 ;
593 ; VIGFX9_10: s_movk_i32 s4, 0xfc0
594 ; VIGFX9_10-DAG: buffer_load_dwordx4 v[0:3], v{{[0-9]+}}, s[0:3], s4 offen offset:68 ;
595 ; VIGFX9_10-DAG: buffer_load_dwordx4 v[4:7], v{{[0-9]+}}, s[0:3], s4 offen offset:84 ;
596 ; VIGFX9_10-DAG: buffer_load_dwordx4 v[8:11], v{{[0-9]+}}, s[0:3], s4 offen offset:100 ;
597 ; VIGFX9_10-DAG: buffer_load_dwordx4 v[12:15], v{{[0-9]+}}, s[0:3], s4 offen offset:116 ;
598 ; GCN: ; return to shader part epilog
599 define amdgpu_ps <16 x float> @smrd_load_nonconst5(<4 x i32> inreg %rsrc, i32 %off) #0 {
601 %off.2 = add i32 %off, 4100
602 %ld = call <16 x i32> @llvm.amdgcn.s.buffer.load.v16i32(<4 x i32> %rsrc, i32 %off.2, i32 0)
603 %bc = bitcast <16 x i32> %ld to <16 x float>
608 ; GCN-LABEL: {{^}}smrd_load_dwordx2:
609 ; SIVIGFX9_10: s_buffer_load_dwordx2 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}}
610 ; CI: s_buffer_load_dwordx2 s[{{[0-9]+:[0-9]+}}], s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}}
612 define amdgpu_ps void @smrd_load_dwordx2(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, ptr addrspace(4) inreg %in, i32 inreg %ncoff) #0 {
614 %tmp22 = load <4 x i32>, ptr addrspace(4) %in
615 %s.buffer = call <2 x i32> @llvm.amdgcn.s.buffer.load.v2i32(<4 x i32> %tmp22, i32 %ncoff, i32 0)
616 %s.buffer.float = bitcast <2 x i32> %s.buffer to <2 x float>
617 %r.1 = extractelement <2 x float> %s.buffer.float, i32 0
618 %r.2 = extractelement <2 x float> %s.buffer.float, i32 1
619 call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float %r.1, float %r.1, float %r.1, float %r.2, i1 true, i1 true) #0
623 ; GCN-LABEL: {{^}}smrd_uniform_loop:
625 ; TODO: we should keep the loop counter in an SGPR
627 ; GCN: s_buffer_load_dword
628 define amdgpu_ps float @smrd_uniform_loop(<4 x i32> inreg %desc, i32 %bound) #0 {
633 %counter = phi i32 [ 0, %main_body ], [ %counter.next, %loop ]
634 %sum = phi float [ 0.0, %main_body ], [ %sum.next, %loop ]
635 %offset = shl i32 %counter, 2
636 %v = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %offset, i32 0)
637 %sum.next = fadd float %sum, %v
638 %counter.next = add i32 %counter, 1
639 %cc = icmp uge i32 %counter.next, %bound
640 br i1 %cc, label %exit, label %loop
647 ; GCN-LABEL: {{^}}smrd_uniform_loop2:
648 ; (this test differs from smrd_uniform_loop by the more complex structure of phis)
650 ; TODO: we should keep the loop counter in an SGPR and use an S_BUFFER_LOAD
652 ; GCN: buffer_load_dword
653 define amdgpu_ps float @smrd_uniform_loop2(<4 x i32> inreg %desc, i32 %bound, i32 %bound.a) #0 {
658 %counter = phi i32 [ 0, %main_body ], [ %counter.next, %loop.a ], [ %counter.next, %loop.b ]
659 %sum = phi float [ 0.0, %main_body ], [ %sum.next, %loop.a ], [ %sum.next.b, %loop.b ]
660 %offset = shl i32 %counter, 2
661 %v = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %desc, i32 %offset, i32 0)
662 %sum.next = fadd float %sum, %v
663 %counter.next = add i32 %counter, 1
664 %cc = icmp uge i32 %counter.next, %bound
665 br i1 %cc, label %exit, label %loop.a
668 %cc.a = icmp uge i32 %counter.next, %bound.a
669 br i1 %cc, label %loop, label %loop.b
672 %sum.next.b = fadd float %sum.next, 1.0
679 ; This test checks that the load after some control flow with an offset based
680 ; on a divergent shader input is correctly recognized as divergent. This was
681 ; reduced from an actual regression. Yes, the %unused argument matters, as
682 ; well as the fact that %arg4 is a vector.
684 ; GCN-LABEL: {{^}}arg_divergence:
685 ; GCN: buffer_load_dword v0, v0,
686 ; GCN-NEXT: s_waitcnt
687 ; GCN-NEXT: ; return to shader part epilog
688 define amdgpu_cs float @arg_divergence(i32 inreg %unused, <3 x i32> %arg4) #0 {
690 br i1 undef, label %if1, label %endif1
692 if1: ; preds = %main_body
693 store i32 0, ptr addrspace(3) undef, align 4
696 endif1: ; preds = %if1, %main_body
697 %tmp13 = extractelement <3 x i32> %arg4, i32 0
698 %tmp97 = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> undef, i32 %tmp13, i32 0)
702 ; GCN-LABEL: {{^}}s_buffer_load_f32:
703 ; GCN: s_buffer_load_dword s0, s[0:3], s4
704 define amdgpu_ps void @s_buffer_load_f32(<4 x i32> inreg %rsrc, i32 inreg %offset) {
705 %sgpr = call float @llvm.amdgcn.s.buffer.load.f32(<4 x i32> %rsrc, i32 %offset, i32 0)
706 call void asm sideeffect "; use $0", "s"(float %sgpr)
710 ; GCN-LABEL: {{^}}s_buffer_load_v2f32:
711 ; GCN: s_buffer_load_dwordx2 s[0:1], s[0:3], s4
712 define amdgpu_ps void @s_buffer_load_v2f32(<4 x i32> inreg %rsrc, i32 inreg %offset) {
713 %sgpr = call <2 x float> @llvm.amdgcn.s.buffer.load.v2f32(<4 x i32> %rsrc, i32 %offset, i32 0)
714 call void asm sideeffect "; use $0", "s"(<2 x float> %sgpr)
718 ; GCN-LABEL: {{^}}s_buffer_load_v4f32:
719 ; GCN: s_buffer_load_dwordx4 s[0:3], s[0:3], s4
720 define amdgpu_ps void @s_buffer_load_v4f32(<4 x i32> inreg %rsrc, i32 inreg %offset) {
721 %sgpr = call <4 x float> @llvm.amdgcn.s.buffer.load.v4f32(<4 x i32> %rsrc, i32 %offset, i32 0)
722 call void asm sideeffect "; use $0", "s"(<4 x float> %sgpr)
726 ; GCN-LABEL: {{^}}s_buffer_load_v8f32:
727 ; GCN: s_buffer_load_dwordx8 s[0:7], s[0:3], s4
728 define amdgpu_ps void @s_buffer_load_v8f32(<4 x i32> inreg %rsrc, i32 inreg %offset) {
729 %sgpr = call <8 x float> @llvm.amdgcn.s.buffer.load.v8f32(<4 x i32> %rsrc, i32 %offset, i32 0)
730 call void asm sideeffect "; use $0", "s"(<8 x float> %sgpr)
734 ; GCN-LABEL: {{^}}s_buffer_load_v16f32:
735 ; GCN: s_buffer_load_dwordx16 s[0:15], s[0:3], s4
736 define amdgpu_ps void @s_buffer_load_v16f32(<4 x i32> inreg %rsrc, i32 inreg %offset) {
737 %sgpr = call <16 x float> @llvm.amdgcn.s.buffer.load.v16f32(<4 x i32> %rsrc, i32 %offset, i32 0)
738 call void asm sideeffect "; use $0", "s"(<16 x float> %sgpr)
742 declare void @llvm.amdgcn.exp.f32(i32, i32, float, float, float, float, i1, i1) #0
743 declare float @llvm.amdgcn.interp.p1(float, i32, i32, i32) #2
744 declare float @llvm.amdgcn.interp.p2(float, float, i32, i32, i32) #2
746 declare i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32>, i32, i32) #1
747 declare <2 x i32> @llvm.amdgcn.s.buffer.load.v2i32(<4 x i32>, i32, i32)
748 declare <4 x i32> @llvm.amdgcn.s.buffer.load.v4i32(<4 x i32>, i32, i32)
749 declare <8 x i32> @llvm.amdgcn.s.buffer.load.v8i32(<4 x i32>, i32, i32)
750 declare <16 x i32> @llvm.amdgcn.s.buffer.load.v16i32(<4 x i32>, i32, i32)
752 declare float @llvm.amdgcn.s.buffer.load.f32(<4 x i32>, i32, i32)
753 declare <2 x float> @llvm.amdgcn.s.buffer.load.v2f32(<4 x i32>, i32, i32)
754 declare <4 x float> @llvm.amdgcn.s.buffer.load.v4f32(<4 x i32>, i32, i32)
755 declare <8 x float> @llvm.amdgcn.s.buffer.load.v8f32(<4 x i32>, i32, i32)
756 declare <16 x float> @llvm.amdgcn.s.buffer.load.v16f32(<4 x i32>, i32, i32)
758 attributes #0 = { nounwind }
759 attributes #1 = { nounwind readnone }
760 attributes #2 = { nounwind readnone speculatable }