1 // RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip -split-input-file %s | FileCheck %s
3 spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
4 // CHECK-LABEL: @group_non_uniform_ballot
5 spirv.func @group_non_uniform_ballot(%predicate: i1) -> vector<4xi32> "None" {
6 // CHECK: %{{.*}} = spirv.GroupNonUniformBallot <Workgroup> %{{.*}}: vector<4xi32>
7 %0 = spirv.GroupNonUniformBallot <Workgroup> %predicate : vector<4xi32>
8 spirv.ReturnValue %0: vector<4xi32>
11 // CHECK-LABEL: @group_non_uniform_broadcast
12 spirv.func @group_non_uniform_broadcast(%value: f32) -> f32 "None" {
13 %one = spirv.Constant 1 : i32
14 // CHECK: spirv.GroupNonUniformBroadcast <Subgroup> %{{.*}}, %{{.*}} : f32, i32
15 %0 = spirv.GroupNonUniformBroadcast <Subgroup> %value, %one : f32, i32
16 spirv.ReturnValue %0: f32
19 // CHECK-LABEL: @group_non_uniform_elect
20 spirv.func @group_non_uniform_elect() -> i1 "None" {
21 // CHECK: %{{.+}} = spirv.GroupNonUniformElect <Workgroup> : i1
22 %0 = spirv.GroupNonUniformElect <Workgroup> : i1
23 spirv.ReturnValue %0: i1
26 // CHECK-LABEL: @group_non_uniform_fadd_reduce
27 spirv.func @group_non_uniform_fadd_reduce(%val: f32) -> f32 "None" {
28 // CHECK: %{{.+}} = spirv.GroupNonUniformFAdd <Workgroup> <Reduce> %{{.+}} : f32 -> f32
29 %0 = spirv.GroupNonUniformFAdd <Workgroup> <Reduce> %val : f32 -> f32
30 spirv.ReturnValue %0: f32
33 // CHECK-LABEL: @group_non_uniform_fmax_reduce
34 spirv.func @group_non_uniform_fmax_reduce(%val: f32) -> f32 "None" {
35 // CHECK: %{{.+}} = spirv.GroupNonUniformFMax <Workgroup> <Reduce> %{{.+}} : f32 -> f32
36 %0 = spirv.GroupNonUniformFMax <Workgroup> <Reduce> %val : f32 -> f32
37 spirv.ReturnValue %0: f32
40 // CHECK-LABEL: @group_non_uniform_fmin_reduce
41 spirv.func @group_non_uniform_fmin_reduce(%val: f32) -> f32 "None" {
42 // CHECK: %{{.+}} = spirv.GroupNonUniformFMin <Workgroup> <Reduce> %{{.+}} : f32 -> f32
43 %0 = spirv.GroupNonUniformFMin <Workgroup> <Reduce> %val : f32 -> f32
44 spirv.ReturnValue %0: f32
47 // CHECK-LABEL: @group_non_uniform_fmul_reduce
48 spirv.func @group_non_uniform_fmul_reduce(%val: f32) -> f32 "None" {
49 // CHECK: %{{.+}} = spirv.GroupNonUniformFMul <Workgroup> <Reduce> %{{.+}} : f32 -> f32
50 %0 = spirv.GroupNonUniformFMul <Workgroup> <Reduce> %val : f32 -> f32
51 spirv.ReturnValue %0: f32
54 // CHECK-LABEL: @group_non_uniform_iadd_reduce
55 spirv.func @group_non_uniform_iadd_reduce(%val: i32) -> i32 "None" {
56 // CHECK: %{{.+}} = spirv.GroupNonUniformIAdd <Workgroup> <Reduce> %{{.+}} : i32 -> i32
57 %0 = spirv.GroupNonUniformIAdd <Workgroup> <Reduce> %val : i32 -> i32
58 spirv.ReturnValue %0: i32
61 // CHECK-LABEL: @group_non_uniform_iadd_clustered_reduce
62 spirv.func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> "None" {
63 %four = spirv.Constant 4 : i32
64 // CHECK: %{{.+}} = spirv.GroupNonUniformIAdd <Workgroup> <ClusteredReduce> %{{.+}} cluster_size(%{{.+}}) : vector<2xi32>, i32 -> vector<2xi32>
65 %0 = spirv.GroupNonUniformIAdd <Workgroup> <ClusteredReduce> %val cluster_size(%four) : vector<2xi32>, i32 -> vector<2xi32>
66 spirv.ReturnValue %0: vector<2xi32>
69 // CHECK-LABEL: @group_non_uniform_imul_reduce
70 spirv.func @group_non_uniform_imul_reduce(%val: i32) -> i32 "None" {
71 // CHECK: %{{.+}} = spirv.GroupNonUniformIMul <Workgroup> <Reduce> %{{.+}} : i32 -> i32
72 %0 = spirv.GroupNonUniformIMul <Workgroup> <Reduce> %val : i32 -> i32
73 spirv.ReturnValue %0: i32
76 // CHECK-LABEL: @group_non_uniform_smax_reduce
77 spirv.func @group_non_uniform_smax_reduce(%val: i32) -> i32 "None" {
78 // CHECK: %{{.+}} = spirv.GroupNonUniformSMax <Workgroup> <Reduce> %{{.+}} : i32 -> i32
79 %0 = spirv.GroupNonUniformSMax <Workgroup> <Reduce> %val : i32 -> i32
80 spirv.ReturnValue %0: i32
83 // CHECK-LABEL: @group_non_uniform_smin_reduce
84 spirv.func @group_non_uniform_smin_reduce(%val: i32) -> i32 "None" {
85 // CHECK: %{{.+}} = spirv.GroupNonUniformSMin <Workgroup> <Reduce> %{{.+}} : i32 -> i32
86 %0 = spirv.GroupNonUniformSMin <Workgroup> <Reduce> %val : i32 -> i32
87 spirv.ReturnValue %0: i32
90 // CHECK-LABEL: @group_non_uniform_umax_reduce
91 spirv.func @group_non_uniform_umax_reduce(%val: i32) -> i32 "None" {
92 // CHECK: %{{.+}} = spirv.GroupNonUniformUMax <Workgroup> <Reduce> %{{.+}} : i32 -> i32
93 %0 = spirv.GroupNonUniformUMax <Workgroup> <Reduce> %val : i32 -> i32
94 spirv.ReturnValue %0: i32
97 // CHECK-LABEL: @group_non_uniform_umin_reduce
98 spirv.func @group_non_uniform_umin_reduce(%val: i32) -> i32 "None" {
99 // CHECK: %{{.+}} = spirv.GroupNonUniformUMin <Workgroup> <Reduce> %{{.+}} : i32 -> i32
100 %0 = spirv.GroupNonUniformUMin <Workgroup> <Reduce> %val : i32 -> i32
101 spirv.ReturnValue %0: i32
104 spirv.func @group_non_uniform_shuffle(%val: f32, %id: i32) -> f32 "None" {
105 // CHECK: %{{.+}} = spirv.GroupNonUniformShuffle <Subgroup> %{{.+}}, %{{.+}} : f32, i32
106 %0 = spirv.GroupNonUniformShuffle <Subgroup> %val, %id : f32, i32
107 spirv.ReturnValue %0: f32
110 spirv.func @group_non_uniform_shuffle_up(%val: f32, %id: i32) -> f32 "None" {
111 // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleUp <Subgroup> %{{.+}}, %{{.+}} : f32, i32
112 %0 = spirv.GroupNonUniformShuffleUp <Subgroup> %val, %id : f32, i32
113 spirv.ReturnValue %0: f32
116 spirv.func @group_non_uniform_shuffle_down(%val: f32, %id: i32) -> f32 "None" {
117 // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleDown <Subgroup> %{{.+}}, %{{.+}} : f32, i32
118 %0 = spirv.GroupNonUniformShuffleDown <Subgroup> %val, %id : f32, i32
119 spirv.ReturnValue %0: f32
122 spirv.func @group_non_uniform_shuffle_xor(%val: f32, %id: i32) -> f32 "None" {
123 // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleXor <Subgroup> %{{.+}}, %{{.+}} : f32, i32
124 %0 = spirv.GroupNonUniformShuffleXor <Subgroup> %val, %id : f32, i32
125 spirv.ReturnValue %0: f32