Skip to content

Commit 711df7b

Browse files
authored
[vector][mlir] Restrict vector.shuffle to fixed-width vectors (#88733)
At the moment there is no support for vector.shuffle for scalable vectors - various hooks/helpers related to `vector.shuffle` simply ignore the scalable flags (e.g. ` ShuffleOp::inferReturnTypes`). This is unlikely to change any time soon (vector shuffles are known to be tricky for scalable vectors), hence this patch restricts `vector.shuffle` to fixed width vectors.
1 parent dadcaf8 commit 711df7b

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

mlir/include/mlir/Dialect/Vector/IR/VectorOps.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def Vector_ShuffleOp :
420420
PredOpTrait<"second operand v2 and result have same element type",
421421
TCresVTEtIsSameAsOpBase<0, 1>>,
422422
InferTypeOpAdaptor]>,
423-
Arguments<(ins AnyVectorOfAnyRank:$v1, AnyVectorOfAnyRank:$v2,
423+
Arguments<(ins AnyFixedVector:$v1, AnyFixedVector:$v2,
424424
I64ArrayAttr:$mask)>,
425425
Results<(outs AnyVector:$vector)> {
426426
let summary = "shuffle operation";
@@ -444,6 +444,8 @@ def Vector_ShuffleOp :
444444
mask values must be within range, viz. given two k-D operands v1 and v2
445445
above, all mask values are in the range [0,s_1+t_1)
446446

447+
Note, scalable vectors are not supported.
448+
447449
Example:
448450

449451
```mlir

mlir/test/Dialect/Vector/canonicalize.mlir

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,14 +1943,6 @@ func.func @shuffle_nofold1(%v0 : vector<4xi32>, %v1 : vector<2xi32>) -> vector<5
19431943
return %shuffle : vector<5xi32>
19441944
}
19451945

1946-
// CHECK-LABEL: func @shuffle_nofold2
1947-
// CHECK: %[[V:.+]] = vector.shuffle %arg0, %arg1 [0, 1, 2, 3] : vector<[4]xi32>, vector<[2]xi32>
1948-
// CHECK: return %[[V]]
1949-
func.func @shuffle_nofold2(%v0 : vector<[4]xi32>, %v1 : vector<[2]xi32>) -> vector<4xi32> {
1950-
%shuffle = vector.shuffle %v0, %v1 [0, 1, 2, 3] : vector<[4]xi32>, vector<[2]xi32>
1951-
return %shuffle : vector<4xi32>
1952-
}
1953-
19541946
// -----
19551947

19561948
// CHECK-LABEL: func @transpose_scalar_broadcast1

mlir/test/Dialect/Vector/invalid.mlir

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ func.func @shuffle_index_out_of_range(%arg0: vector<2xf32>, %arg1: vector<2xf32>
8484

8585
// -----
8686

87+
func.func @shuffle_scalable_vec(%arg0: vector<[2]xf32>, %arg1: vector<[2]xf32>) {
88+
// expected-error@+1 {{'vector.shuffle' op operand #0 must be fixed-length vector of any type values}}
89+
%1 = vector.shuffle %arg0, %arg1 [0, 1, 2, 3] : vector<[2]xf32>, vector<[2]xf32>
90+
}
91+
92+
// -----
93+
8794
func.func @shuffle_empty_mask(%arg0: vector<2xf32>, %arg1: vector<2xf32>) {
8895
// expected-error@+1 {{'vector.shuffle' op invalid mask length}}
8996
%1 = vector.shuffle %arg0, %arg1 [] : vector<2xf32>, vector<2xf32>

0 commit comments

Comments
 (0)