1 ;; #pragma OPENCL EXTENSION cl_khr_subgroup_shuffle_relative : enable
2 ;; #pragma OPENCL EXTENSION cl_khr_fp16 : enable
3 ;; #pragma OPENCL EXTENSION cl_khr_fp64 : enable
5 ;; kernel void testShuffleRelativeChar(global char* dst)
8 ;; dst[0] = sub_group_shuffle_up( v, 0 );
9 ;; dst[1] = sub_group_shuffle_down( v, 0 );
12 ;; kernel void testShuffleRelativeUChar(global uchar* dst)
15 ;; dst[0] = sub_group_shuffle_up( v, 0 );
16 ;; dst[1] = sub_group_shuffle_down( v, 0 );
19 ;; kernel void testShuffleRelativeShort(global short* dst)
22 ;; dst[0] = sub_group_shuffle_up( v, 0 );
23 ;; dst[1] = sub_group_shuffle_down( v, 0 );
26 ;; kernel void testShuffleRelativeUShort(global ushort* dst)
29 ;; dst[0] = sub_group_shuffle_up( v, 0 );
30 ;; dst[1] = sub_group_shuffle_down( v, 0 );
33 ;; kernel void testShuffleRelativeInt(global int* dst)
36 ;; dst[0] = sub_group_shuffle_up( v, 0 );
37 ;; dst[1] = sub_group_shuffle_down( v, 0 );
40 ;; kernel void testShuffleRelativeUInt(global uint* dst)
43 ;; dst[0] = sub_group_shuffle_up( v, 0 );
44 ;; dst[1] = sub_group_shuffle_down( v, 0 );
47 ;; kernel void testShuffleRelativeLong(global long* dst)
50 ;; dst[0] = sub_group_shuffle_up( v, 0 );
51 ;; dst[1] = sub_group_shuffle_down( v, 0 );
54 ;; kernel void testShuffleRelativeULong(global ulong* dst)
57 ;; dst[0] = sub_group_shuffle_up( v, 0 );
58 ;; dst[1] = sub_group_shuffle_down( v, 0 );
61 ;; kernel void testShuffleRelativeFloat(global float* dst)
64 ;; dst[0] = sub_group_shuffle_up( v, 0 );
65 ;; dst[1] = sub_group_shuffle_down( v, 0 );
68 ;; kernel void testShuffleRelativeHalf(global half* dst)
71 ;; dst[0] = sub_group_shuffle_up( v, 0 );
72 ;; dst[1] = sub_group_shuffle_down( v, 0 );
75 ;; kernel void testShuffleRelativeDouble(global double* dst)
78 ;; dst[0] = sub_group_shuffle_up( v, 0 );
79 ;; dst[1] = sub_group_shuffle_down( v, 0 );
82 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
83 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
85 ; CHECK-SPIRV-DAG: OpCapability GroupNonUniformShuffleRelative
87 ; CHECK-SPIRV-DAG: %[[#char:]] = OpTypeInt 8 0
88 ; CHECK-SPIRV-DAG: %[[#short:]] = OpTypeInt 16 0
89 ; CHECK-SPIRV-DAG: %[[#int:]] = OpTypeInt 32 0
90 ; CHECK-SPIRV-DAG: %[[#long:]] = OpTypeInt 64 0
91 ; CHECK-SPIRV-DAG: %[[#half:]] = OpTypeFloat 16
92 ; CHECK-SPIRV-DAG: %[[#float:]] = OpTypeFloat 32
93 ; CHECK-SPIRV-DAG: %[[#double:]] = OpTypeFloat 64
95 ; CHECK-SPIRV-DAG: %[[#ScopeSubgroup:]] = OpConstant %[[#int]] 3
96 ; CHECK-SPIRV-DAG: %[[#char_0:]] = OpConstant %[[#char]] 0
97 ; CHECK-SPIRV-DAG: %[[#short_0:]] = OpConstant %[[#short]] 0
98 ; CHECK-SPIRV-DAG: %[[#int_0:]] = OpConstant %[[#int]] 0
99 ; CHECK-SPIRV-DAG: %[[#long_0:]] = OpConstantNull %[[#long]]
100 ; CHECK-SPIRV-DAG: %[[#half_0:]] = OpConstant %[[#half]] 0
101 ; CHECK-SPIRV-DAG: %[[#float_0:]] = OpConstant %[[#float]] 0
102 ; CHECK-SPIRV-DAG: %[[#double_0:]] = OpConstant %[[#double]] 0
104 ; CHECK-SPIRV: OpFunction
105 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
106 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
107 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
108 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
109 ; CHECK-SPIRV: OpFunctionEnd
111 define dso_local spir_kernel void @testShuffleRelativeChar(i8 addrspace(1)* nocapture) local_unnamed_addr {
112 %2 = tail call spir_func signext i8 @_Z20sub_group_shuffle_upcj(i8 signext 0, i32 0)
113 %w2 = tail call spir_func i8 @__spirv_GroupNonUniformShuffleUp(i32 3, i8 signext 0, i32 0)
114 store i8 %2, i8 addrspace(1)* %0, align 1
115 %3 = tail call spir_func signext i8 @_Z22sub_group_shuffle_downcj(i8 signext 0, i32 0)
116 %w3 = tail call spir_func i8 @__spirv_GroupNonUniformShuffleDown(i32 3, i8 signext 0, i32 0)
117 %4 = getelementptr inbounds i8, i8 addrspace(1)* %0, i64 1
118 store i8 %3, i8 addrspace(1)* %4, align 1
122 declare dso_local spir_func signext i8 @_Z20sub_group_shuffle_upcj(i8 signext, i32) local_unnamed_addr
124 declare dso_local spir_func signext i8 @_Z22sub_group_shuffle_downcj(i8 signext, i32) local_unnamed_addr
126 declare dso_local spir_func i8 @__spirv_GroupNonUniformShuffleUp(i32, i8, i32)
128 declare dso_local spir_func i8 @__spirv_GroupNonUniformShuffleDown(i32, i8, i32)
130 ; CHECK-SPIRV: OpFunction
131 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
132 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
133 ; CHECK-SPIRV: OpFunctionEnd
135 define dso_local spir_kernel void @testShuffleRelativeUChar(i8 addrspace(1)* nocapture) local_unnamed_addr {
136 %2 = tail call spir_func zeroext i8 @_Z20sub_group_shuffle_uphj(i8 zeroext 0, i32 0)
137 store i8 %2, i8 addrspace(1)* %0, align 1
138 %3 = tail call spir_func zeroext i8 @_Z22sub_group_shuffle_downhj(i8 zeroext 0, i32 0)
139 %4 = getelementptr inbounds i8, i8 addrspace(1)* %0, i64 1
140 store i8 %3, i8 addrspace(1)* %4, align 1
144 declare dso_local spir_func zeroext i8 @_Z20sub_group_shuffle_uphj(i8 zeroext, i32) local_unnamed_addr
146 declare dso_local spir_func zeroext i8 @_Z22sub_group_shuffle_downhj(i8 zeroext, i32) local_unnamed_addr
148 ; CHECK-SPIRV: OpFunction
149 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
150 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
151 ; CHECK-SPIRV: OpFunctionEnd
153 define dso_local spir_kernel void @testShuffleRelativeShort(i16 addrspace(1)* nocapture) local_unnamed_addr {
154 %2 = tail call spir_func signext i16 @_Z20sub_group_shuffle_upsj(i16 signext 0, i32 0)
155 store i16 %2, i16 addrspace(1)* %0, align 2
156 %3 = tail call spir_func signext i16 @_Z22sub_group_shuffle_downsj(i16 signext 0, i32 0)
157 %4 = getelementptr inbounds i16, i16 addrspace(1)* %0, i64 1
158 store i16 %3, i16 addrspace(1)* %4, align 2
162 declare dso_local spir_func signext i16 @_Z20sub_group_shuffle_upsj(i16 signext, i32) local_unnamed_addr
164 declare dso_local spir_func signext i16 @_Z22sub_group_shuffle_downsj(i16 signext, i32) local_unnamed_addr
166 ; CHECK-SPIRV: OpFunction
167 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
168 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
169 ; CHECK-SPIRV: OpFunctionEnd
171 define dso_local spir_kernel void @testShuffleRelativeUShort(i16 addrspace(1)* nocapture) local_unnamed_addr {
172 %2 = tail call spir_func zeroext i16 @_Z20sub_group_shuffle_uptj(i16 zeroext 0, i32 0)
173 store i16 %2, i16 addrspace(1)* %0, align 2
174 %3 = tail call spir_func zeroext i16 @_Z22sub_group_shuffle_downtj(i16 zeroext 0, i32 0)
175 %4 = getelementptr inbounds i16, i16 addrspace(1)* %0, i64 1
176 store i16 %3, i16 addrspace(1)* %4, align 2
180 declare dso_local spir_func zeroext i16 @_Z20sub_group_shuffle_uptj(i16 zeroext, i32) local_unnamed_addr
182 declare dso_local spir_func zeroext i16 @_Z22sub_group_shuffle_downtj(i16 zeroext, i32) local_unnamed_addr
184 ; CHECK-SPIRV: OpFunction
185 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
186 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
187 ; CHECK-SPIRV: OpFunctionEnd
189 define dso_local spir_kernel void @testShuffleRelativeInt(i32 addrspace(1)* nocapture) local_unnamed_addr {
190 %2 = tail call spir_func i32 @_Z20sub_group_shuffle_upij(i32 0, i32 0)
191 store i32 %2, i32 addrspace(1)* %0, align 4
192 %3 = tail call spir_func i32 @_Z22sub_group_shuffle_downij(i32 0, i32 0)
193 %4 = getelementptr inbounds i32, i32 addrspace(1)* %0, i64 1
194 store i32 %3, i32 addrspace(1)* %4, align 4
198 declare dso_local spir_func i32 @_Z20sub_group_shuffle_upij(i32, i32) local_unnamed_addr
200 declare dso_local spir_func i32 @_Z22sub_group_shuffle_downij(i32, i32) local_unnamed_addr
202 ; CHECK-SPIRV: OpFunction
203 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
204 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
205 ; CHECK-SPIRV: OpFunctionEnd
207 define dso_local spir_kernel void @testShuffleRelativeUInt(i32 addrspace(1)* nocapture) local_unnamed_addr {
208 %2 = tail call spir_func i32 @_Z20sub_group_shuffle_upjj(i32 0, i32 0)
209 store i32 %2, i32 addrspace(1)* %0, align 4
210 %3 = tail call spir_func i32 @_Z22sub_group_shuffle_downjj(i32 0, i32 0)
211 %4 = getelementptr inbounds i32, i32 addrspace(1)* %0, i64 1
212 store i32 %3, i32 addrspace(1)* %4, align 4
216 declare dso_local spir_func i32 @_Z20sub_group_shuffle_upjj(i32, i32) local_unnamed_addr
218 declare dso_local spir_func i32 @_Z22sub_group_shuffle_downjj(i32, i32) local_unnamed_addr
220 ; CHECK-SPIRV: OpFunction
221 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
222 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
223 ; CHECK-SPIRV: OpFunctionEnd
225 define dso_local spir_kernel void @testShuffleRelativeLong(i64 addrspace(1)* nocapture) local_unnamed_addr {
226 %2 = tail call spir_func i64 @_Z20sub_group_shuffle_uplj(i64 0, i32 0)
227 store i64 %2, i64 addrspace(1)* %0, align 8
228 %3 = tail call spir_func i64 @_Z22sub_group_shuffle_downlj(i64 0, i32 0)
229 %4 = getelementptr inbounds i64, i64 addrspace(1)* %0, i64 1
230 store i64 %3, i64 addrspace(1)* %4, align 8
234 declare dso_local spir_func i64 @_Z20sub_group_shuffle_uplj(i64, i32) local_unnamed_addr
236 declare dso_local spir_func i64 @_Z22sub_group_shuffle_downlj(i64, i32) local_unnamed_addr
238 ; CHECK-SPIRV: OpFunction
239 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
240 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
241 ; CHECK-SPIRV: OpFunctionEnd
243 define dso_local spir_kernel void @testShuffleRelativeULong(i64 addrspace(1)* nocapture) local_unnamed_addr {
244 %2 = tail call spir_func i64 @_Z20sub_group_shuffle_upmj(i64 0, i32 0)
245 store i64 %2, i64 addrspace(1)* %0, align 8
246 %3 = tail call spir_func i64 @_Z22sub_group_shuffle_downmj(i64 0, i32 0)
247 %4 = getelementptr inbounds i64, i64 addrspace(1)* %0, i64 1
248 store i64 %3, i64 addrspace(1)* %4, align 8
252 declare dso_local spir_func i64 @_Z20sub_group_shuffle_upmj(i64, i32) local_unnamed_addr
254 declare dso_local spir_func i64 @_Z22sub_group_shuffle_downmj(i64, i32) local_unnamed_addr
256 ; CHECK-SPIRV: OpFunction
257 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#float]] %[[#ScopeSubgroup]] %[[#float_0]] %[[#int_0]]
258 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#float]] %[[#ScopeSubgroup]] %[[#float_0]] %[[#int_0]]
259 ; CHECK-SPIRV: OpFunctionEnd
261 define dso_local spir_kernel void @testShuffleRelativeFloat(float addrspace(1)* nocapture) local_unnamed_addr {
262 %2 = tail call spir_func float @_Z20sub_group_shuffle_upfj(float 0.000000e+00, i32 0)
263 store float %2, float addrspace(1)* %0, align 4
264 %3 = tail call spir_func float @_Z22sub_group_shuffle_downfj(float 0.000000e+00, i32 0)
265 %4 = getelementptr inbounds float, float addrspace(1)* %0, i64 1
266 store float %3, float addrspace(1)* %4, align 4
270 declare dso_local spir_func float @_Z20sub_group_shuffle_upfj(float, i32) local_unnamed_addr
272 declare dso_local spir_func float @_Z22sub_group_shuffle_downfj(float, i32) local_unnamed_addr
274 ; CHECK-SPIRV: OpFunction
275 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#half]] %[[#ScopeSubgroup]] %[[#half_0]] %[[#int_0]]
276 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#half]] %[[#ScopeSubgroup]] %[[#half_0]] %[[#int_0]]
277 ; CHECK-SPIRV: OpFunctionEnd
279 define dso_local spir_kernel void @testShuffleRelativeHalf(half addrspace(1)* nocapture) local_unnamed_addr {
280 %2 = tail call spir_func half @_Z20sub_group_shuffle_upDhj(half 0xH0000, i32 0)
281 store half %2, half addrspace(1)* %0, align 2
282 %3 = tail call spir_func half @_Z22sub_group_shuffle_downDhj(half 0xH0000, i32 0)
283 %4 = getelementptr inbounds half, half addrspace(1)* %0, i64 1
284 store half %3, half addrspace(1)* %4, align 2
288 declare dso_local spir_func half @_Z20sub_group_shuffle_upDhj(half, i32) local_unnamed_addr
290 declare dso_local spir_func half @_Z22sub_group_shuffle_downDhj(half, i32) local_unnamed_addr
292 ; CHECK-SPIRV: OpFunction
293 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#double]] %[[#ScopeSubgroup]] %[[#double_0]] %[[#int_0]]
294 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#double]] %[[#ScopeSubgroup]] %[[#double_0]] %[[#int_0]]
295 ; CHECK-SPIRV: OpFunctionEnd
297 define dso_local spir_kernel void @testShuffleRelativeDouble(double addrspace(1)* nocapture) local_unnamed_addr {
298 %2 = tail call spir_func double @_Z20sub_group_shuffle_updj(double 0.000000e+00, i32 0)
299 store double %2, double addrspace(1)* %0, align 8
300 %3 = tail call spir_func double @_Z22sub_group_shuffle_downdj(double 0.000000e+00, i32 0)
301 %4 = getelementptr inbounds double, double addrspace(1)* %0, i64 1
302 store double %3, double addrspace(1)* %4, align 8
306 declare dso_local spir_func double @_Z20sub_group_shuffle_updj(double, i32) local_unnamed_addr
308 declare dso_local spir_func double @_Z22sub_group_shuffle_downdj(double, i32) local_unnamed_addr