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: @subgroup_ballot
5 spirv.func @subgroup_ballot(%predicate: i1) -> vector<4xi32> "None" {
6 // CHECK: %{{.*}} = spirv.KHR.SubgroupBallot %{{.*}}: vector<4xi32>
7 %0 = spirv.KHR.SubgroupBallot %predicate: vector<4xi32>
8 spirv.ReturnValue %0: vector<4xi32>
10 // CHECK-LABEL: @group_broadcast_1
11 spirv.func @group_broadcast_1(%value: f32, %localid: i32 ) -> f32 "None" {
12 // CHECK: spirv.GroupBroadcast <Workgroup> %{{.*}}, %{{.*}} : f32, i32
13 %0 = spirv.GroupBroadcast <Workgroup> %value, %localid : f32, i32
14 spirv.ReturnValue %0: f32
16 // CHECK-LABEL: @group_broadcast_2
17 spirv.func @group_broadcast_2(%value: f32, %localid: vector<3xi32> ) -> f32 "None" {
18 // CHECK: spirv.GroupBroadcast <Workgroup> %{{.*}}, %{{.*}} : f32, vector<3xi32>
19 %0 = spirv.GroupBroadcast <Workgroup> %value, %localid : f32, vector<3xi32>
20 spirv.ReturnValue %0: f32
22 // CHECK-LABEL: @subgroup_block_read_intel
23 spirv.func @subgroup_block_read_intel(%ptr : !spirv.ptr<i32, StorageBuffer>) -> i32 "None" {
24 // CHECK: spirv.INTEL.SubgroupBlockRead %{{.*}} : !spirv.ptr<i32, StorageBuffer> -> i32
25 %0 = spirv.INTEL.SubgroupBlockRead %ptr : !spirv.ptr<i32, StorageBuffer> -> i32
26 spirv.ReturnValue %0: i32
28 // CHECK-LABEL: @subgroup_block_read_intel_vector
29 spirv.func @subgroup_block_read_intel_vector(%ptr : !spirv.ptr<i32, StorageBuffer>) -> vector<3xi32> "None" {
30 // CHECK: spirv.INTEL.SubgroupBlockRead %{{.*}} : !spirv.ptr<i32, StorageBuffer> -> vector<3xi32>
31 %0 = spirv.INTEL.SubgroupBlockRead %ptr : !spirv.ptr<i32, StorageBuffer> -> vector<3xi32>
32 spirv.ReturnValue %0: vector<3xi32>
34 // CHECK-LABEL: @subgroup_block_write_intel
35 spirv.func @subgroup_block_write_intel(%ptr : !spirv.ptr<i32, StorageBuffer>, %value: i32) -> () "None" {
36 // CHECK: spirv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : i32
37 spirv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : i32
40 // CHECK-LABEL: @subgroup_block_write_intel_vector
41 spirv.func @subgroup_block_write_intel_vector(%ptr : !spirv.ptr<i32, StorageBuffer>, %value: vector<3xi32>) -> () "None" {
42 // CHECK: spirv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : vector<3xi32>
43 spirv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : vector<3xi32>
46 // CHECK-LABEL: @group_iadd
47 spirv.func @group_iadd(%value: i32) -> i32 "None" {
48 // CHECK: spirv.GroupIAdd <Workgroup> <Reduce> %{{.*}} : i32
49 %0 = spirv.GroupIAdd <Workgroup> <Reduce> %value : i32
50 spirv.ReturnValue %0: i32
52 // CHECK-LABEL: @group_fadd
53 spirv.func @group_fadd(%value: f32) -> f32 "None" {
54 // CHECK: spirv.GroupFAdd <Workgroup> <Reduce> %{{.*}} : f32
55 %0 = spirv.GroupFAdd <Workgroup> <Reduce> %value : f32
56 spirv.ReturnValue %0: f32
58 // CHECK-LABEL: @group_fmin
59 spirv.func @group_fmin(%value: f32) -> f32 "None" {
60 // CHECK: spirv.GroupFMin <Workgroup> <Reduce> %{{.*}} : f32
61 %0 = spirv.GroupFMin <Workgroup> <Reduce> %value : f32
62 spirv.ReturnValue %0: f32
64 // CHECK-LABEL: @group_umin
65 spirv.func @group_umin(%value: i32) -> i32 "None" {
66 // CHECK: spirv.GroupUMin <Workgroup> <Reduce> %{{.*}} : i32
67 %0 = spirv.GroupUMin <Workgroup> <Reduce> %value : i32
68 spirv.ReturnValue %0: i32
70 // CHECK-LABEL: @group_smin
71 spirv.func @group_smin(%value: i32) -> i32 "None" {
72 // CHECK: spirv.GroupSMin <Workgroup> <Reduce> %{{.*}} : i32
73 %0 = spirv.GroupSMin <Workgroup> <Reduce> %value : i32
74 spirv.ReturnValue %0: i32
76 // CHECK-LABEL: @group_fmax
77 spirv.func @group_fmax(%value: f32) -> f32 "None" {
78 // CHECK: spirv.GroupFMax <Workgroup> <Reduce> %{{.*}} : f32
79 %0 = spirv.GroupFMax <Workgroup> <Reduce> %value : f32
80 spirv.ReturnValue %0: f32
82 // CHECK-LABEL: @group_umax
83 spirv.func @group_umax(%value: i32) -> i32 "None" {
84 // CHECK: spirv.GroupUMax <Workgroup> <Reduce> %{{.*}} : i32
85 %0 = spirv.GroupUMax <Workgroup> <Reduce> %value : i32
86 spirv.ReturnValue %0: i32
88 // CHECK-LABEL: @group_smax
89 spirv.func @group_smax(%value: i32) -> i32 "None" {
90 // CHECK: spirv.GroupSMax <Workgroup> <Reduce> %{{.*}} : i32
91 %0 = spirv.GroupSMax <Workgroup> <Reduce> %value : i32
92 spirv.ReturnValue %0: i32
94 // CHECK-LABEL: @group_imul
95 spirv.func @group_imul(%value: i32) -> i32 "None" {
96 // CHECK: spirv.KHR.GroupIMul <Workgroup> <Reduce> %{{.*}} : i32
97 %0 = spirv.KHR.GroupIMul <Workgroup> <Reduce> %value : i32
98 spirv.ReturnValue %0: i32
100 // CHECK-LABEL: @group_fmul
101 spirv.func @group_fmul(%value: f32) -> f32 "None" {
102 // CHECK: spirv.KHR.GroupFMul <Workgroup> <Reduce> %{{.*}} : f32
103 %0 = spirv.KHR.GroupFMul <Workgroup> <Reduce> %value : f32
104 spirv.ReturnValue %0: f32