1// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s 2 3//===----------------------------------------------------------------------===// 4// spv.SubgroupBallotKHR 5//===----------------------------------------------------------------------===// 6 7func @subgroup_ballot(%predicate: i1) -> vector<4xi32> { 8 // CHECK: %{{.*}} = spv.SubgroupBallotKHR %{{.*}} : vector<4xi32> 9 %0 = spv.SubgroupBallotKHR %predicate: vector<4xi32> 10 return %0: vector<4xi32> 11} 12 13// ----- 14 15//===----------------------------------------------------------------------===// 16// spv.GroupBroadcast 17//===----------------------------------------------------------------------===// 18 19func @group_broadcast_scalar(%value: f32, %localid: i32 ) -> f32 { 20 // CHECK: spv.GroupBroadcast "Workgroup" %{{.*}}, %{{.*}} : f32, i32 21 %0 = spv.GroupBroadcast "Workgroup" %value, %localid : f32, i32 22 return %0: f32 23} 24 25// ----- 26 27func @group_broadcast_scalar_vector(%value: f32, %localid: vector<3xi32> ) -> f32 { 28 // CHECK: spv.GroupBroadcast "Workgroup" %{{.*}}, %{{.*}} : f32, vector<3xi32> 29 %0 = spv.GroupBroadcast "Workgroup" %value, %localid : f32, vector<3xi32> 30 return %0: f32 31} 32 33// ----- 34 35func @group_broadcast_vector(%value: vector<4xf32>, %localid: vector<3xi32> ) -> vector<4xf32> { 36 // CHECK: spv.GroupBroadcast "Subgroup" %{{.*}}, %{{.*}} : vector<4xf32>, vector<3xi32> 37 %0 = spv.GroupBroadcast "Subgroup" %value, %localid : vector<4xf32>, vector<3xi32> 38 return %0: vector<4xf32> 39} 40 41// ----- 42 43func @group_broadcast_negative_scope(%value: f32, %localid: vector<3xi32> ) -> f32 { 44 // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} 45 %0 = spv.GroupBroadcast "Device" %value, %localid : f32, vector<3xi32> 46 return %0: f32 47} 48 49// ----- 50 51func @group_broadcast_negative_locid_dtype(%value: f32, %localid: vector<3xf32> ) -> f32 { 52 // expected-error @+1 {{operand #1 must be 8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values}} 53 %0 = spv.GroupBroadcast "Subgroup" %value, %localid : f32, vector<3xf32> 54 return %0: f32 55} 56 57// ----- 58 59func @group_broadcast_negative_locid_vec4(%value: f32, %localid: vector<4xi32> ) -> f32 { 60 // expected-error @+1 {{localid is a vector and can be with only 2 or 3 components, actual number is 4}} 61 %0 = spv.GroupBroadcast "Subgroup" %value, %localid : f32, vector<4xi32> 62 return %0: f32 63} 64 65// ----- 66 67//===----------------------------------------------------------------------===// 68// spv.SubgroupBlockReadINTEL 69//===----------------------------------------------------------------------===// 70 71func @subgroup_block_read_intel(%ptr : !spv.ptr<i32, StorageBuffer>) -> i32 { 72 // CHECK: spv.SubgroupBlockReadINTEL %{{.*}} : i32 73 %0 = spv.SubgroupBlockReadINTEL "StorageBuffer" %ptr : i32 74 return %0: i32 75} 76 77// ----- 78 79func @subgroup_block_read_intel_vector(%ptr : !spv.ptr<i32, StorageBuffer>) -> vector<3xi32> { 80 // CHECK: spv.SubgroupBlockReadINTEL %{{.*}} : vector<3xi32> 81 %0 = spv.SubgroupBlockReadINTEL "StorageBuffer" %ptr : vector<3xi32> 82 return %0: vector<3xi32> 83} 84 85// ----- 86 87//===----------------------------------------------------------------------===// 88// spv.SubgroupBlockWriteINTEL 89//===----------------------------------------------------------------------===// 90 91func @subgroup_block_write_intel(%ptr : !spv.ptr<i32, StorageBuffer>, %value: i32) -> () { 92 // CHECK: spv.SubgroupBlockWriteINTEL %{{.*}}, %{{.*}} : i32 93 spv.SubgroupBlockWriteINTEL "StorageBuffer" %ptr, %value : i32 94 return 95} 96 97// ----- 98 99func @subgroup_block_write_intel_vector(%ptr : !spv.ptr<i32, StorageBuffer>, %value: vector<3xi32>) -> () { 100 // CHECK: spv.SubgroupBlockWriteINTEL %{{.*}}, %{{.*}} : vector<3xi32> 101 spv.SubgroupBlockWriteINTEL "StorageBuffer" %ptr, %value : vector<3xi32> 102 return 103}