[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.

GitOrigin-RevId: 711df7b0ae4a9ea45e431d5c0ff4a0c8b2e732c1
diff --git a/include/mlir/Dialect/Vector/IR/VectorOps.td b/include/mlir/Dialect/Vector/IR/VectorOps.td
index 147bc23..332b5ad 100644
--- a/include/mlir/Dialect/Vector/IR/VectorOps.td
+++ b/include/mlir/Dialect/Vector/IR/VectorOps.td
@@ -420,7 +420,7 @@
      PredOpTrait<"second operand v2 and result have same element type",
                  TCresVTEtIsSameAsOpBase<0, 1>>,
      InferTypeOpAdaptor]>,
-     Arguments<(ins AnyVectorOfAnyRank:$v1, AnyVectorOfAnyRank:$v2,
+     Arguments<(ins AnyFixedVector:$v1, AnyFixedVector:$v2,
                     I64ArrayAttr:$mask)>,
      Results<(outs AnyVector:$vector)> {
   let summary = "shuffle operation";
@@ -444,6 +444,8 @@
       mask values must be within range, viz. given two k-D operands v1 and v2
       above, all mask values are in the range [0,s_1+t_1)
 
+    Note, scalable vectors are not supported.
+
     Example:
 
     ```mlir
diff --git a/test/Dialect/Vector/canonicalize.mlir b/test/Dialect/Vector/canonicalize.mlir
index 627ac54..61a5f2a 100644
--- a/test/Dialect/Vector/canonicalize.mlir
+++ b/test/Dialect/Vector/canonicalize.mlir
@@ -1943,14 +1943,6 @@
   return %shuffle : vector<5xi32>
 }
 
-// CHECK-LABEL: func @shuffle_nofold2
-//       CHECK:   %[[V:.+]] = vector.shuffle %arg0, %arg1 [0, 1, 2, 3] : vector<[4]xi32>, vector<[2]xi32>
-//       CHECK:   return %[[V]]
-func.func @shuffle_nofold2(%v0 : vector<[4]xi32>, %v1 : vector<[2]xi32>) -> vector<4xi32> {
-  %shuffle = vector.shuffle %v0, %v1 [0, 1, 2, 3] : vector<[4]xi32>, vector<[2]xi32>
-  return %shuffle : vector<4xi32>
-}
-
 // -----
 
 // CHECK-LABEL: func @transpose_scalar_broadcast1
diff --git a/test/Dialect/Vector/invalid.mlir b/test/Dialect/Vector/invalid.mlir
index c16f1cb..c9f7e9c 100644
--- a/test/Dialect/Vector/invalid.mlir
+++ b/test/Dialect/Vector/invalid.mlir
@@ -84,6 +84,13 @@
 
 // -----
 
+func.func @shuffle_scalable_vec(%arg0: vector<[2]xf32>, %arg1: vector<[2]xf32>) {
+  // expected-error@+1 {{'vector.shuffle' op operand #0 must be fixed-length vector of any type values}}
+  %1 = vector.shuffle %arg0, %arg1 [0, 1, 2, 3] : vector<[2]xf32>, vector<[2]xf32>
+}
+
+// -----
+
 func.func @shuffle_empty_mask(%arg0: vector<2xf32>, %arg1: vector<2xf32>) {
   // expected-error@+1 {{'vector.shuffle' op invalid mask length}}
   %1 = vector.shuffle %arg0, %arg1 [] : vector<2xf32>, vector<2xf32>