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 -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
84 ; CHECK-SPIRV-DAG: OpCapability GroupNonUniformShuffleRelative
86 ; CHECK-SPIRV-DAG: %[[#char:]] = OpTypeInt 8 0
87 ; CHECK-SPIRV-DAG: %[[#short:]] = OpTypeInt 16 0
88 ; CHECK-SPIRV-DAG: %[[#int:]] = OpTypeInt 32 0
89 ; CHECK-SPIRV-DAG: %[[#long:]] = OpTypeInt 64 0
90 ; CHECK-SPIRV-DAG: %[[#half:]] = OpTypeFloat 16
91 ; CHECK-SPIRV-DAG: %[[#float:]] = OpTypeFloat 32
92 ; CHECK-SPIRV-DAG: %[[#double:]] = OpTypeFloat 64
94 ; CHECK-SPIRV-DAG: %[[#ScopeSubgroup:]] = OpConstant %[[#int]] 3
95 ; CHECK-SPIRV-DAG: %[[#char_0:]] = OpConstant %[[#char]] 0
96 ; CHECK-SPIRV-DAG: %[[#short_0:]] = OpConstant %[[#short]] 0
97 ; CHECK-SPIRV-DAG: %[[#int_0:]] = OpConstant %[[#int]] 0
98 ; CHECK-SPIRV-DAG: %[[#long_0:]] = OpConstantNull %[[#long]]
99 ; CHECK-SPIRV-DAG: %[[#half_0:]] = OpConstant %[[#half]] 0
100 ; CHECK-SPIRV-DAG: %[[#float_0:]] = OpConstant %[[#float]] 0
101 ; CHECK-SPIRV-DAG: %[[#double_0:]] = OpConstant %[[#double]] 0
103 ; CHECK-SPIRV: OpFunction
104 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
105 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
106 ; CHECK-SPIRV: OpFunctionEnd
108 define dso_local spir_kernel void @testShuffleRelativeChar(i8 addrspace(1)* nocapture) local_unnamed_addr {
109 %2 = tail call spir_func signext i8 @_Z20sub_group_shuffle_upcj(i8 signext 0, i32 0)
110 store i8 %2, i8 addrspace(1)* %0, align 1
111 %3 = tail call spir_func signext i8 @_Z22sub_group_shuffle_downcj(i8 signext 0, i32 0)
112 %4 = getelementptr inbounds i8, i8 addrspace(1)* %0, i64 1
113 store i8 %3, i8 addrspace(1)* %4, align 1
117 declare dso_local spir_func signext i8 @_Z20sub_group_shuffle_upcj(i8 signext, i32) local_unnamed_addr
119 declare dso_local spir_func signext i8 @_Z22sub_group_shuffle_downcj(i8 signext, i32) local_unnamed_addr
121 ; CHECK-SPIRV: OpFunction
122 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
123 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
124 ; CHECK-SPIRV: OpFunctionEnd
126 define dso_local spir_kernel void @testShuffleRelativeUChar(i8 addrspace(1)* nocapture) local_unnamed_addr {
127 %2 = tail call spir_func zeroext i8 @_Z20sub_group_shuffle_uphj(i8 zeroext 0, i32 0)
128 store i8 %2, i8 addrspace(1)* %0, align 1
129 %3 = tail call spir_func zeroext i8 @_Z22sub_group_shuffle_downhj(i8 zeroext 0, i32 0)
130 %4 = getelementptr inbounds i8, i8 addrspace(1)* %0, i64 1
131 store i8 %3, i8 addrspace(1)* %4, align 1
135 declare dso_local spir_func zeroext i8 @_Z20sub_group_shuffle_uphj(i8 zeroext, i32) local_unnamed_addr
137 declare dso_local spir_func zeroext i8 @_Z22sub_group_shuffle_downhj(i8 zeroext, i32) local_unnamed_addr
139 ; CHECK-SPIRV: OpFunction
140 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
141 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
142 ; CHECK-SPIRV: OpFunctionEnd
144 define dso_local spir_kernel void @testShuffleRelativeShort(i16 addrspace(1)* nocapture) local_unnamed_addr {
145 %2 = tail call spir_func signext i16 @_Z20sub_group_shuffle_upsj(i16 signext 0, i32 0)
146 store i16 %2, i16 addrspace(1)* %0, align 2
147 %3 = tail call spir_func signext i16 @_Z22sub_group_shuffle_downsj(i16 signext 0, i32 0)
148 %4 = getelementptr inbounds i16, i16 addrspace(1)* %0, i64 1
149 store i16 %3, i16 addrspace(1)* %4, align 2
153 declare dso_local spir_func signext i16 @_Z20sub_group_shuffle_upsj(i16 signext, i32) local_unnamed_addr
155 declare dso_local spir_func signext i16 @_Z22sub_group_shuffle_downsj(i16 signext, i32) local_unnamed_addr
157 ; CHECK-SPIRV: OpFunction
158 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
159 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
160 ; CHECK-SPIRV: OpFunctionEnd
162 define dso_local spir_kernel void @testShuffleRelativeUShort(i16 addrspace(1)* nocapture) local_unnamed_addr {
163 %2 = tail call spir_func zeroext i16 @_Z20sub_group_shuffle_uptj(i16 zeroext 0, i32 0)
164 store i16 %2, i16 addrspace(1)* %0, align 2
165 %3 = tail call spir_func zeroext i16 @_Z22sub_group_shuffle_downtj(i16 zeroext 0, i32 0)
166 %4 = getelementptr inbounds i16, i16 addrspace(1)* %0, i64 1
167 store i16 %3, i16 addrspace(1)* %4, align 2
171 declare dso_local spir_func zeroext i16 @_Z20sub_group_shuffle_uptj(i16 zeroext, i32) local_unnamed_addr
173 declare dso_local spir_func zeroext i16 @_Z22sub_group_shuffle_downtj(i16 zeroext, i32) local_unnamed_addr
175 ; CHECK-SPIRV: OpFunction
176 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
177 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
178 ; CHECK-SPIRV: OpFunctionEnd
180 define dso_local spir_kernel void @testShuffleRelativeInt(i32 addrspace(1)* nocapture) local_unnamed_addr {
181 %2 = tail call spir_func i32 @_Z20sub_group_shuffle_upij(i32 0, i32 0)
182 store i32 %2, i32 addrspace(1)* %0, align 4
183 %3 = tail call spir_func i32 @_Z22sub_group_shuffle_downij(i32 0, i32 0)
184 %4 = getelementptr inbounds i32, i32 addrspace(1)* %0, i64 1
185 store i32 %3, i32 addrspace(1)* %4, align 4
189 declare dso_local spir_func i32 @_Z20sub_group_shuffle_upij(i32, i32) local_unnamed_addr
191 declare dso_local spir_func i32 @_Z22sub_group_shuffle_downij(i32, i32) local_unnamed_addr
193 ; CHECK-SPIRV: OpFunction
194 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
195 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
196 ; CHECK-SPIRV: OpFunctionEnd
198 define dso_local spir_kernel void @testShuffleRelativeUInt(i32 addrspace(1)* nocapture) local_unnamed_addr {
199 %2 = tail call spir_func i32 @_Z20sub_group_shuffle_upjj(i32 0, i32 0)
200 store i32 %2, i32 addrspace(1)* %0, align 4
201 %3 = tail call spir_func i32 @_Z22sub_group_shuffle_downjj(i32 0, i32 0)
202 %4 = getelementptr inbounds i32, i32 addrspace(1)* %0, i64 1
203 store i32 %3, i32 addrspace(1)* %4, align 4
207 declare dso_local spir_func i32 @_Z20sub_group_shuffle_upjj(i32, i32) local_unnamed_addr
209 declare dso_local spir_func i32 @_Z22sub_group_shuffle_downjj(i32, i32) local_unnamed_addr
211 ; CHECK-SPIRV: OpFunction
212 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
213 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
214 ; CHECK-SPIRV: OpFunctionEnd
216 define dso_local spir_kernel void @testShuffleRelativeLong(i64 addrspace(1)* nocapture) local_unnamed_addr {
217 %2 = tail call spir_func i64 @_Z20sub_group_shuffle_uplj(i64 0, i32 0)
218 store i64 %2, i64 addrspace(1)* %0, align 8
219 %3 = tail call spir_func i64 @_Z22sub_group_shuffle_downlj(i64 0, i32 0)
220 %4 = getelementptr inbounds i64, i64 addrspace(1)* %0, i64 1
221 store i64 %3, i64 addrspace(1)* %4, align 8
225 declare dso_local spir_func i64 @_Z20sub_group_shuffle_uplj(i64, i32) local_unnamed_addr
227 declare dso_local spir_func i64 @_Z22sub_group_shuffle_downlj(i64, i32) local_unnamed_addr
229 ; CHECK-SPIRV: OpFunction
230 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
231 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
232 ; CHECK-SPIRV: OpFunctionEnd
234 define dso_local spir_kernel void @testShuffleRelativeULong(i64 addrspace(1)* nocapture) local_unnamed_addr {
235 %2 = tail call spir_func i64 @_Z20sub_group_shuffle_upmj(i64 0, i32 0)
236 store i64 %2, i64 addrspace(1)* %0, align 8
237 %3 = tail call spir_func i64 @_Z22sub_group_shuffle_downmj(i64 0, i32 0)
238 %4 = getelementptr inbounds i64, i64 addrspace(1)* %0, i64 1
239 store i64 %3, i64 addrspace(1)* %4, align 8
243 declare dso_local spir_func i64 @_Z20sub_group_shuffle_upmj(i64, i32) local_unnamed_addr
245 declare dso_local spir_func i64 @_Z22sub_group_shuffle_downmj(i64, i32) local_unnamed_addr
247 ; CHECK-SPIRV: OpFunction
248 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#float]] %[[#ScopeSubgroup]] %[[#float_0]] %[[#int_0]]
249 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#float]] %[[#ScopeSubgroup]] %[[#float_0]] %[[#int_0]]
250 ; CHECK-SPIRV: OpFunctionEnd
252 define dso_local spir_kernel void @testShuffleRelativeFloat(float addrspace(1)* nocapture) local_unnamed_addr {
253 %2 = tail call spir_func float @_Z20sub_group_shuffle_upfj(float 0.000000e+00, i32 0)
254 store float %2, float addrspace(1)* %0, align 4
255 %3 = tail call spir_func float @_Z22sub_group_shuffle_downfj(float 0.000000e+00, i32 0)
256 %4 = getelementptr inbounds float, float addrspace(1)* %0, i64 1
257 store float %3, float addrspace(1)* %4, align 4
261 declare dso_local spir_func float @_Z20sub_group_shuffle_upfj(float, i32) local_unnamed_addr
263 declare dso_local spir_func float @_Z22sub_group_shuffle_downfj(float, i32) local_unnamed_addr
265 ; CHECK-SPIRV: OpFunction
266 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#half]] %[[#ScopeSubgroup]] %[[#half_0]] %[[#int_0]]
267 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#half]] %[[#ScopeSubgroup]] %[[#half_0]] %[[#int_0]]
268 ; CHECK-SPIRV: OpFunctionEnd
270 define dso_local spir_kernel void @testShuffleRelativeHalf(half addrspace(1)* nocapture) local_unnamed_addr {
271 %2 = tail call spir_func half @_Z20sub_group_shuffle_upDhj(half 0xH0000, i32 0)
272 store half %2, half addrspace(1)* %0, align 2
273 %3 = tail call spir_func half @_Z22sub_group_shuffle_downDhj(half 0xH0000, i32 0)
274 %4 = getelementptr inbounds half, half addrspace(1)* %0, i64 1
275 store half %3, half addrspace(1)* %4, align 2
279 declare dso_local spir_func half @_Z20sub_group_shuffle_upDhj(half, i32) local_unnamed_addr
281 declare dso_local spir_func half @_Z22sub_group_shuffle_downDhj(half, i32) local_unnamed_addr
283 ; CHECK-SPIRV: OpFunction
284 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleUp %[[#double]] %[[#ScopeSubgroup]] %[[#double_0]] %[[#int_0]]
285 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleDown %[[#double]] %[[#ScopeSubgroup]] %[[#double_0]] %[[#int_0]]
286 ; CHECK-SPIRV: OpFunctionEnd
288 define dso_local spir_kernel void @testShuffleRelativeDouble(double addrspace(1)* nocapture) local_unnamed_addr {
289 %2 = tail call spir_func double @_Z20sub_group_shuffle_updj(double 0.000000e+00, i32 0)
290 store double %2, double addrspace(1)* %0, align 8
291 %3 = tail call spir_func double @_Z22sub_group_shuffle_downdj(double 0.000000e+00, i32 0)
292 %4 = getelementptr inbounds double, double addrspace(1)* %0, i64 1
293 store double %3, double addrspace(1)* %4, align 8
297 declare dso_local spir_func double @_Z20sub_group_shuffle_updj(double, i32) local_unnamed_addr
299 declare dso_local spir_func double @_Z22sub_group_shuffle_downdj(double, i32) local_unnamed_addr