1 // RUN: mlir-opt -split-input-file -convert-gpu-to-spirv -verify-diagnostics %s -o - | FileCheck %s
5 spirv.target_env = #spirv.target_env<#spirv.vce<v1.4, [Shader, GroupNonUniformShuffle], []>, #spirv.resource_limits<subgroup_size = 16>>
9 // CHECK-LABEL: spirv.func @shuffle_xor()
10 gpu.func @shuffle_xor() kernel
11 attributes {spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [16, 1, 1]>} {
12 %mask = arith.constant 8 : i32
13 %width = arith.constant 16 : i32
14 %val = arith.constant 42.0 : f32
16 // CHECK: %[[MASK:.+]] = spirv.Constant 8 : i32
17 // CHECK: %[[VAL:.+]] = spirv.Constant 4.200000e+01 : f32
18 // CHECK: %{{.+}} = spirv.Constant true
19 // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleXor <Subgroup> %[[VAL]], %[[MASK]] : f32, i32
20 %result, %valid = gpu.shuffle xor %val, %mask, %width : f32
31 spirv.target_env = #spirv.target_env<#spirv.vce<v1.4, [Shader, GroupNonUniformShuffle], []>, #spirv.resource_limits<subgroup_size = 32>>
35 gpu.func @shuffle_xor() kernel
36 attributes {spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [16, 1, 1]>} {
37 %mask = arith.constant 8 : i32
38 %width = arith.constant 16 : i32
39 %val = arith.constant 42.0 : f32
41 // Cannot convert due to shuffle width and target subgroup size mismatch
42 // expected-error @+1 {{failed to legalize operation 'gpu.shuffle'}}
43 %result, %valid = gpu.shuffle xor %val, %mask, %width : f32
54 spirv.target_env = #spirv.target_env<#spirv.vce<v1.4, [Shader, GroupNonUniformShuffle], []>, #spirv.resource_limits<subgroup_size = 16>>
58 // CHECK-LABEL: spirv.func @shuffle_idx()
59 gpu.func @shuffle_idx() kernel
60 attributes {spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [16, 1, 1]>} {
61 %mask = arith.constant 8 : i32
62 %width = arith.constant 16 : i32
63 %val = arith.constant 42.0 : f32
65 // CHECK: %[[MASK:.+]] = spirv.Constant 8 : i32
66 // CHECK: %[[VAL:.+]] = spirv.Constant 4.200000e+01 : f32
67 // CHECK: %{{.+}} = spirv.Constant true
68 // CHECK: %{{.+}} = spirv.GroupNonUniformShuffle <Subgroup> %[[VAL]], %[[MASK]] : f32, i32
69 %result, %valid = gpu.shuffle idx %val, %mask, %width : f32