1 ;; #pragma OPENCL EXTENSION cl_khr_subgroup_shuffle : enable
2 ;; #pragma OPENCL EXTENSION cl_khr_fp16 : enable
3 ;; #pragma OPENCL EXTENSION cl_khr_fp64 : enable
5 ;; kernel void testShuffleChar(global char* dst)
8 ;; dst[0] = sub_group_shuffle( v, 0 );
9 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
12 ;; kernel void testShuffleUChar(global uchar* dst)
15 ;; dst[0] = sub_group_shuffle( v, 0 );
16 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
19 ;; kernel void testShuffleShort(global short* dst)
22 ;; dst[0] = sub_group_shuffle( v, 0 );
23 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
26 ;; kernel void testShuffleUShort(global ushort* dst)
29 ;; dst[0] = sub_group_shuffle( v, 0 );
30 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
33 ;; kernel void testShuffleInt(global int* dst)
36 ;; dst[0] = sub_group_shuffle( v, 0 );
37 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
40 ;; kernel void testShuffleUInt(global uint* dst)
43 ;; dst[0] = sub_group_shuffle( v, 0 );
44 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
47 ;; kernel void testShuffleLong(global long* dst)
50 ;; dst[0] = sub_group_shuffle( v, 0 );
51 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
54 ;; kernel void testShuffleULong(global ulong* dst)
57 ;; dst[0] = sub_group_shuffle( v, 0 );
58 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
61 ;; kernel void testShuffleFloat(global float* dst)
64 ;; dst[0] = sub_group_shuffle( v, 0 );
65 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
68 ;; kernel void testShuffleHalf(global half* dst)
71 ;; dst[0] = sub_group_shuffle( v, 0 );
72 ;; dst[1] = sub_group_shuffle_xor( v, 0 );
75 ;; kernel void testShuffleDouble(global double* dst)
78 ;; dst[0] = sub_group_shuffle( v, 0 );
79 ;; dst[1] = sub_group_shuffle_xor( 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 GroupNonUniformShuffle
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: %[[#]] = OpGroupNonUniformShuffle %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
106 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
107 ; CHECK-SPIRV: OpFunctionEnd
109 define dso_local spir_kernel void @testShuffleChar(i8 addrspace(1)* nocapture) local_unnamed_addr {
110 %2 = tail call spir_func signext i8 @_Z17sub_group_shufflecj(i8 signext 0, i32 0)
111 %r2 = tail call spir_func signext i8 @__spirv_GroupNonUniformShuffle(i32 3, i8 signext 0, i32 0)
112 store i8 %2, i8 addrspace(1)* %0, align 1
113 %3 = tail call spir_func signext i8 @_Z21sub_group_shuffle_xorcj(i8 signext 0, i32 0)
114 %r3 = tail call spir_func signext i8 @__spirv_GroupNonUniformShuffleXor(i32 3, i8 signext 0, i32 0)
115 %4 = getelementptr inbounds i8, i8 addrspace(1)* %0, i64 1
116 store i8 %3, i8 addrspace(1)* %4, align 1
120 declare dso_local spir_func signext i8 @_Z17sub_group_shufflecj(i8 signext, i32) local_unnamed_addr
121 declare dso_local spir_func signext i8 @__spirv_GroupNonUniformShuffle(i32, i8 signext, i32)
123 declare dso_local spir_func signext i8 @_Z21sub_group_shuffle_xorcj(i8 signext, i32) local_unnamed_addr
124 declare dso_local spir_func signext i8 @__spirv_GroupNonUniformShuffleXor(i32, i8 signext, i32)
126 ; CHECK-SPIRV: OpFunction
127 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
128 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#char]] %[[#ScopeSubgroup]] %[[#char_0]] %[[#int_0]]
129 ; CHECK-SPIRV: OpFunctionEnd
131 define dso_local spir_kernel void @testShuffleUChar(i8 addrspace(1)* nocapture) local_unnamed_addr {
132 %2 = tail call spir_func zeroext i8 @_Z17sub_group_shufflehj(i8 zeroext 0, i32 0)
133 store i8 %2, i8 addrspace(1)* %0, align 1
134 %3 = tail call spir_func zeroext i8 @_Z21sub_group_shuffle_xorhj(i8 zeroext 0, i32 0)
135 %4 = getelementptr inbounds i8, i8 addrspace(1)* %0, i64 1
136 store i8 %3, i8 addrspace(1)* %4, align 1
140 declare dso_local spir_func zeroext i8 @_Z17sub_group_shufflehj(i8 zeroext, i32) local_unnamed_addr
142 declare dso_local spir_func zeroext i8 @_Z21sub_group_shuffle_xorhj(i8 zeroext, i32) local_unnamed_addr
144 ; CHECK-SPIRV: OpFunction
145 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
146 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
147 ; CHECK-SPIRV: OpFunctionEnd
149 define dso_local spir_kernel void @testShuffleShort(i16 addrspace(1)* nocapture) local_unnamed_addr {
150 %2 = tail call spir_func signext i16 @_Z17sub_group_shufflesj(i16 signext 0, i32 0)
151 store i16 %2, i16 addrspace(1)* %0, align 2
152 %3 = tail call spir_func signext i16 @_Z21sub_group_shuffle_xorsj(i16 signext 0, i32 0)
153 %4 = getelementptr inbounds i16, i16 addrspace(1)* %0, i64 1
154 store i16 %3, i16 addrspace(1)* %4, align 2
158 declare dso_local spir_func signext i16 @_Z17sub_group_shufflesj(i16 signext, i32) local_unnamed_addr
160 declare dso_local spir_func signext i16 @_Z21sub_group_shuffle_xorsj(i16 signext, i32) local_unnamed_addr
162 ; CHECK-SPIRV: OpFunction
163 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
164 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#short]] %[[#ScopeSubgroup]] %[[#short_0]] %[[#int_0]]
165 ; CHECK-SPIRV: OpFunctionEnd
167 define dso_local spir_kernel void @testShuffleUShort(i16 addrspace(1)* nocapture) local_unnamed_addr {
168 %2 = tail call spir_func zeroext i16 @_Z17sub_group_shuffletj(i16 zeroext 0, i32 0)
169 store i16 %2, i16 addrspace(1)* %0, align 2
170 %3 = tail call spir_func zeroext i16 @_Z21sub_group_shuffle_xortj(i16 zeroext 0, i32 0)
171 %4 = getelementptr inbounds i16, i16 addrspace(1)* %0, i64 1
172 store i16 %3, i16 addrspace(1)* %4, align 2
176 declare dso_local spir_func zeroext i16 @_Z17sub_group_shuffletj(i16 zeroext, i32) local_unnamed_addr
178 declare dso_local spir_func zeroext i16 @_Z21sub_group_shuffle_xortj(i16 zeroext, i32) local_unnamed_addr
180 ; CHECK-SPIRV: OpFunction
181 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
182 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
183 ; CHECK-SPIRV: OpFunctionEnd
185 define dso_local spir_kernel void @testShuffleInt(i32 addrspace(1)* nocapture) local_unnamed_addr {
186 %2 = tail call spir_func i32 @_Z17sub_group_shuffleij(i32 0, i32 0)
187 store i32 %2, i32 addrspace(1)* %0, align 4
188 %3 = tail call spir_func i32 @_Z21sub_group_shuffle_xorij(i32 0, i32 0)
189 %4 = getelementptr inbounds i32, i32 addrspace(1)* %0, i64 1
190 store i32 %3, i32 addrspace(1)* %4, align 4
194 declare dso_local spir_func i32 @_Z17sub_group_shuffleij(i32, i32) local_unnamed_addr
196 declare dso_local spir_func i32 @_Z21sub_group_shuffle_xorij(i32, i32) local_unnamed_addr
198 ; CHECK-SPIRV: OpFunction
199 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
200 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#int]] %[[#ScopeSubgroup]] %[[#int_0]] %[[#int_0]]
201 ; CHECK-SPIRV: OpFunctionEnd
203 define dso_local spir_kernel void @testShuffleUInt(i32 addrspace(1)* nocapture) local_unnamed_addr {
204 %2 = tail call spir_func i32 @_Z17sub_group_shufflejj(i32 0, i32 0)
205 store i32 %2, i32 addrspace(1)* %0, align 4
206 %3 = tail call spir_func i32 @_Z21sub_group_shuffle_xorjj(i32 0, i32 0)
207 %4 = getelementptr inbounds i32, i32 addrspace(1)* %0, i64 1
208 store i32 %3, i32 addrspace(1)* %4, align 4
212 declare dso_local spir_func i32 @_Z17sub_group_shufflejj(i32, i32) local_unnamed_addr
214 declare dso_local spir_func i32 @_Z21sub_group_shuffle_xorjj(i32, i32) local_unnamed_addr
216 ; CHECK-SPIRV: OpFunction
217 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
218 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
219 ; CHECK-SPIRV: OpFunctionEnd
221 define dso_local spir_kernel void @testShuffleLong(i64 addrspace(1)* nocapture) local_unnamed_addr {
222 %2 = tail call spir_func i64 @_Z17sub_group_shufflelj(i64 0, i32 0)
223 store i64 %2, i64 addrspace(1)* %0, align 8
224 %3 = tail call spir_func i64 @_Z21sub_group_shuffle_xorlj(i64 0, i32 0)
225 %4 = getelementptr inbounds i64, i64 addrspace(1)* %0, i64 1
226 store i64 %3, i64 addrspace(1)* %4, align 8
230 declare dso_local spir_func i64 @_Z17sub_group_shufflelj(i64, i32) local_unnamed_addr
232 declare dso_local spir_func i64 @_Z21sub_group_shuffle_xorlj(i64, i32) local_unnamed_addr
234 ; CHECK-SPIRV: OpFunction
235 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
236 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#long]] %[[#ScopeSubgroup]] %[[#long_0]] %[[#int_0]]
237 ; CHECK-SPIRV: OpFunctionEnd
239 define dso_local spir_kernel void @testShuffleULong(i64 addrspace(1)* nocapture) local_unnamed_addr {
240 %2 = tail call spir_func i64 @_Z17sub_group_shufflemj(i64 0, i32 0)
241 store i64 %2, i64 addrspace(1)* %0, align 8
242 %3 = tail call spir_func i64 @_Z21sub_group_shuffle_xormj(i64 0, i32 0)
243 %4 = getelementptr inbounds i64, i64 addrspace(1)* %0, i64 1
244 store i64 %3, i64 addrspace(1)* %4, align 8
248 declare dso_local spir_func i64 @_Z17sub_group_shufflemj(i64, i32) local_unnamed_addr
250 declare dso_local spir_func i64 @_Z21sub_group_shuffle_xormj(i64, i32) local_unnamed_addr
252 ; CHECK-SPIRV: OpFunction
253 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#float]] %[[#ScopeSubgroup]] %[[#float_0]] %[[#int_0]]
254 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#float]] %[[#ScopeSubgroup]] %[[#float_0]] %[[#int_0]]
255 ; CHECK-SPIRV: OpFunctionEnd
257 define dso_local spir_kernel void @testShuffleFloat(float addrspace(1)* nocapture) local_unnamed_addr {
258 %2 = tail call spir_func float @_Z17sub_group_shufflefj(float 0.000000e+00, i32 0)
259 store float %2, float addrspace(1)* %0, align 4
260 %3 = tail call spir_func float @_Z21sub_group_shuffle_xorfj(float 0.000000e+00, i32 0)
261 %4 = getelementptr inbounds float, float addrspace(1)* %0, i64 1
262 store float %3, float addrspace(1)* %4, align 4
266 declare dso_local spir_func float @_Z17sub_group_shufflefj(float, i32) local_unnamed_addr
268 declare dso_local spir_func float @_Z21sub_group_shuffle_xorfj(float, i32) local_unnamed_addr
270 ; CHECK-SPIRV: OpFunction
271 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#half]] %[[#ScopeSubgroup]] %[[#half_0]] %[[#int_0]]
272 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#half]] %[[#ScopeSubgroup]] %[[#half_0]] %[[#int_0]]
273 ; CHECK-SPIRV: OpFunctionEnd
275 define dso_local spir_kernel void @testShuffleHalf(half addrspace(1)* nocapture) local_unnamed_addr {
276 %2 = tail call spir_func half @_Z17sub_group_shuffleDhj(half 0xH0000, i32 0)
277 store half %2, half addrspace(1)* %0, align 2
278 %3 = tail call spir_func half @_Z21sub_group_shuffle_xorDhj(half 0xH0000, i32 0)
279 %4 = getelementptr inbounds half, half addrspace(1)* %0, i64 1
280 store half %3, half addrspace(1)* %4, align 2
284 declare dso_local spir_func half @_Z17sub_group_shuffleDhj(half, i32) local_unnamed_addr
286 declare dso_local spir_func half @_Z21sub_group_shuffle_xorDhj(half, i32) local_unnamed_addr
288 ; CHECK-SPIRV: OpFunction
289 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffle %[[#double]] %[[#ScopeSubgroup]] %[[#double_0]] %[[#int_0]]
290 ; CHECK-SPIRV: %[[#]] = OpGroupNonUniformShuffleXor %[[#double]] %[[#ScopeSubgroup]] %[[#double_0]] %[[#int_0]]
291 ; CHECK-SPIRV: OpFunctionEnd
293 define dso_local spir_kernel void @testShuffleDouble(double addrspace(1)* nocapture) local_unnamed_addr {
294 %2 = tail call spir_func double @_Z17sub_group_shuffledj(double 0.000000e+00, i32 0)
295 store double %2, double addrspace(1)* %0, align 8
296 %3 = tail call spir_func double @_Z21sub_group_shuffle_xordj(double 0.000000e+00, i32 0)
297 %4 = getelementptr inbounds double, double addrspace(1)* %0, i64 1
298 store double %3, double addrspace(1)* %4, align 8
302 declare dso_local spir_func double @_Z17sub_group_shuffledj(double, i32) local_unnamed_addr
304 declare dso_local spir_func double @_Z21sub_group_shuffle_xordj(double, i32) local_unnamed_addr