[Mlir-commits] [mlir] [mlir][Vector] Fix out-of-bounds crash unrolling create_mask/constant_mask with rank-mismatched native shape (PR #217514)
Aman Singh
llvmlistbot at llvm.org
Sat Sep 5 02:42:37 PDT 2026
================
@@ -602,6 +602,57 @@ func.func @vector_constant_mask() -> vector<16x16xi1> {
// -----
+// A tile lying entirely outside the mask in one dim must be emitted as an
+// all-zeros mask: `constant_mask` rejects a mix of zero and non-zero sizes.
+
+func.func @vector_constant_mask_empty_tile() -> vector<16x16xi1> {
+ %0 = vector.constant_mask [4, 10] : vector<16x16xi1>
+ return %0 : vector<16x16xi1>
+}
+
+// CHECK-LABEL: func @vector_constant_mask_empty_tile
+// CHECK-DAG: arith.constant dense<false> : vector<16x16xi1>
+// CHECK-DAG: arith.constant dense<false> : vector<8x8xi1>
+// CHECK: vector.constant_mask [4, 8] : vector<8x8xi1>
+// CHECK: vector.constant_mask [4, 2] : vector<8x8xi1>
+// Negative check: no partially-zero tile is emitted.
+// CHECK-NOT: vector.constant_mask [0,
+
+// -----
+
+// The target shape used by this test pass is fixed at rank 2, so a rank-3 op
+// exercises the leading-unit-dim padding. See #217175.
+
+func.func @vector_create_mask_rank_mismatch(%size1: index) -> vector<2x8x8xi1> {
+ %c8 = arith.constant 8 : index
+ %0 = vector.create_mask %c8, %size1, %c8 : vector<2x8x8xi1>
+ return %0 : vector<2x8x8xi1>
+}
+
+// CHECK-LABEL: func @vector_create_mask_rank_mismatch
+// CHECK: vector.create_mask {{.*}} : vector<1x8x8xi1>
+// CHECK: vector.insert_strided_slice {{.*}} offsets = [0, 0, 0], strides = [1, 1, 1] : vector<1x8x8xi1> into vector<2x8x8xi1>
+// CHECK: vector.create_mask {{.*}} : vector<1x8x8xi1>
+// CHECK: vector.insert_strided_slice {{.*}} offsets = [1, 0, 0], strides = [1, 1, 1] : vector<1x8x8xi1> into vector<2x8x8xi1>
+
+// -----
+
+func.func @vector_constant_mask_rank_mismatch() -> vector<2x8x8xi1> {
+ %0 = vector.constant_mask [1, 4, 8] : vector<2x8x8xi1>
+ return %0 : vector<2x8x8xi1>
+}
+
+// CHECK-LABEL: func @vector_constant_mask_rank_mismatch
+// CHECK-DAG: arith.constant dense<false> : vector<2x8x8xi1>
+// CHECK-DAG: arith.constant dense<false> : vector<1x8x8xi1>
+// CHECK: vector.constant_mask [1, 4, 8] : vector<1x8x8xi1>
+// CHECK: vector.insert_strided_slice {{.*}} offsets = [0, 0, 0], strides = [1, 1, 1] : vector<1x8x8xi1> into vector<2x8x8xi1>
+// CHECK: vector.insert_strided_slice {{.*}} offsets = [1, 0, 0], strides = [1, 1, 1] : vector<1x8x8xi1> into vector<2x8x8xi1>
+// Negative check: no partially-zero tile is emitted.
----------------
amanyagami wrote:
Removed in 5fa18685d3. I also dropped the third one of the same kind, above `@vector_multi_reduction_rank_mismatch`, so the test file has no explanatory prose left — only the negative-check markers you asked for.
https://github.com/llvm/llvm-project/pull/217514
More information about the Mlir-commits
mailing list