1// RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s
2
3spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
4  // CHECK-LABEL: @group_non_uniform_ballot
5  spv.func @group_non_uniform_ballot(%predicate: i1) -> vector<4xi32> "None" {
6    // CHECK: %{{.*}} = spv.GroupNonUniformBallot "Workgroup" %{{.*}}: vector<4xi32>
7  %0 = spv.GroupNonUniformBallot "Workgroup" %predicate : vector<4xi32>
8    spv.ReturnValue %0: vector<4xi32>
9  }
10
11  // CHECK-LABEL: @group_non_uniform_broadcast
12  spv.func @group_non_uniform_broadcast(%value: f32) -> f32 "None" {
13    %one = spv.constant 1 : i32
14    // CHECK: spv.GroupNonUniformBroadcast "Subgroup" %{{.*}}, %{{.*}} : f32, i32
15    %0 = spv.GroupNonUniformBroadcast "Subgroup" %value, %one : f32, i32
16    spv.ReturnValue %0: f32
17  }
18
19  // CHECK-LABEL: @group_non_uniform_elect
20  spv.func @group_non_uniform_elect() -> i1 "None" {
21    // CHECK: %{{.+}} = spv.GroupNonUniformElect "Workgroup" : i1
22    %0 = spv.GroupNonUniformElect "Workgroup" : i1
23    spv.ReturnValue %0: i1
24  }
25
26  // CHECK-LABEL: @group_non_uniform_fadd_reduce
27  spv.func @group_non_uniform_fadd_reduce(%val: f32) -> f32 "None" {
28    // CHECK: %{{.+}} = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %{{.+}} : f32
29    %0 = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %val : f32
30    spv.ReturnValue %0: f32
31  }
32
33  // CHECK-LABEL: @group_non_uniform_fmax_reduce
34  spv.func @group_non_uniform_fmax_reduce(%val: f32) -> f32 "None" {
35    // CHECK: %{{.+}} = spv.GroupNonUniformFMax "Workgroup" "Reduce" %{{.+}} : f32
36    %0 = spv.GroupNonUniformFMax "Workgroup" "Reduce" %val : f32
37    spv.ReturnValue %0: f32
38  }
39
40  // CHECK-LABEL: @group_non_uniform_fmin_reduce
41  spv.func @group_non_uniform_fmin_reduce(%val: f32) -> f32 "None" {
42    // CHECK: %{{.+}} = spv.GroupNonUniformFMin "Workgroup" "Reduce" %{{.+}} : f32
43    %0 = spv.GroupNonUniformFMin "Workgroup" "Reduce" %val : f32
44    spv.ReturnValue %0: f32
45  }
46
47  // CHECK-LABEL: @group_non_uniform_fmul_reduce
48  spv.func @group_non_uniform_fmul_reduce(%val: f32) -> f32 "None" {
49    // CHECK: %{{.+}} = spv.GroupNonUniformFMul "Workgroup" "Reduce" %{{.+}} : f32
50    %0 = spv.GroupNonUniformFMul "Workgroup" "Reduce" %val : f32
51    spv.ReturnValue %0: f32
52  }
53
54  // CHECK-LABEL: @group_non_uniform_iadd_reduce
55  spv.func @group_non_uniform_iadd_reduce(%val: i32) -> i32 "None" {
56    // CHECK: %{{.+}} = spv.GroupNonUniformIAdd "Workgroup" "Reduce" %{{.+}} : i32
57    %0 = spv.GroupNonUniformIAdd "Workgroup" "Reduce" %val : i32
58    spv.ReturnValue %0: i32
59  }
60
61  // CHECK-LABEL: @group_non_uniform_iadd_clustered_reduce
62  spv.func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> "None" {
63    %four = spv.constant 4 : i32
64    // CHECK: %{{.+}} = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xi32>
65    %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xi32>
66    spv.ReturnValue %0: vector<2xi32>
67  }
68
69  // CHECK-LABEL: @group_non_uniform_imul_reduce
70  spv.func @group_non_uniform_imul_reduce(%val: i32) -> i32 "None" {
71    // CHECK: %{{.+}} = spv.GroupNonUniformIMul "Workgroup" "Reduce" %{{.+}} : i32
72    %0 = spv.GroupNonUniformIMul "Workgroup" "Reduce" %val : i32
73    spv.ReturnValue %0: i32
74  }
75
76  // CHECK-LABEL: @group_non_uniform_smax_reduce
77  spv.func @group_non_uniform_smax_reduce(%val: i32) -> i32 "None" {
78    // CHECK: %{{.+}} = spv.GroupNonUniformSMax "Workgroup" "Reduce" %{{.+}} : i32
79    %0 = spv.GroupNonUniformSMax "Workgroup" "Reduce" %val : i32
80    spv.ReturnValue %0: i32
81  }
82
83  // CHECK-LABEL: @group_non_uniform_smin_reduce
84  spv.func @group_non_uniform_smin_reduce(%val: i32) -> i32 "None" {
85    // CHECK: %{{.+}} = spv.GroupNonUniformSMin "Workgroup" "Reduce" %{{.+}} : i32
86    %0 = spv.GroupNonUniformSMin "Workgroup" "Reduce" %val : i32
87    spv.ReturnValue %0: i32
88  }
89
90  // CHECK-LABEL: @group_non_uniform_umax_reduce
91  spv.func @group_non_uniform_umax_reduce(%val: i32) -> i32 "None" {
92    // CHECK: %{{.+}} = spv.GroupNonUniformUMax "Workgroup" "Reduce" %{{.+}} : i32
93    %0 = spv.GroupNonUniformUMax "Workgroup" "Reduce" %val : i32
94    spv.ReturnValue %0: i32
95  }
96
97  // CHECK-LABEL: @group_non_uniform_umin_reduce
98  spv.func @group_non_uniform_umin_reduce(%val: i32) -> i32 "None" {
99    // CHECK: %{{.+}} = spv.GroupNonUniformUMin "Workgroup" "Reduce" %{{.+}} : i32
100    %0 = spv.GroupNonUniformUMin "Workgroup" "Reduce" %val : i32
101    spv.ReturnValue %0: i32
102  }
103}
104