[Mlir-commits] [mlir] [mlir][vector] Preserve dynamic mask bounds in shape cast folding (PR #229699)
Federico Bruzzone
llvmlistbot at llvm.org
Wed Oct 7 12:54:15 PDT 2026
================
@@ -3590,6 +3607,40 @@ func.func @fold_shape_cast_with_mask_leading_unit(%arg0: tensor<1x?xf32>) -> vec
// -----
+// CHECK-LABEL: func.func @fold_shape_cast_with_mask_leading_unit_dynamic(
+// CHECK-SAME: %[[N:.*]]: index) -> vector<8xi1> {
+func.func @fold_shape_cast_with_mask_leading_unit_dynamic(%n: index) -> vector<8xi1> {
+// CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
+// CHECK-DAG: %[[C8:.*]] = arith.constant 8 : index
+// CHECK: %[[MASK:.*]] = vector.create_mask %[[C1]], %[[N]], %[[C8]] : vector<1x1x8xi1>
+// CHECK: %[[CAST:.*]] = vector.shape_cast %[[MASK]] : vector<1x1x8xi1> to vector<8xi1>
+// CHECK: return %[[CAST]] : vector<8xi1>
+ %c1 = arith.constant 1 : index
+ %c8 = arith.constant 8 : index
+ %mask = vector.create_mask %c1, %n, %c8 : vector<1x1x8xi1>
+ %cast = vector.shape_cast %mask : vector<1x1x8xi1> to vector<8xi1>
+ return %cast : vector<8xi1>
+}
+
+// -----
+
+// CHECK-LABEL: func.func @fold_shape_cast_with_mask_leading_unit_dynamic_mixed_bounds(
+// CHECK-SAME: %[[N:.*]]: index, %[[M:.*]]: index) -> vector<8x4xi1> {
+func.func @fold_shape_cast_with_mask_leading_unit_dynamic_mixed_bounds(%n: index, %m: index) -> vector<8x4xi1> {
----------------
FedericoBruzzone wrote:
Please check if it already exists :D
https://github.com/llvm/llvm-project/pull/229699
More information about the Mlir-commits
mailing list