1- // RUN: mlir-opt %s -split-input-file -test-eliminate-vector-masks  | FileCheck %s 
1+ // RUN: mlir-opt %s -split-input-file -test-eliminate-vector-masks --split-input-file  | FileCheck %s 
22
33// This tests a general pattern the vectorizer tends to emit. 
44
55// CHECK-LABEL: @eliminate_redundant_masks_through_insert_and_extracts 
6- // CHECK: %[[ALL_TRUE_MASK:.*]] = arith.constant dense<true>  : vector<[4]xi1> 
6+ // CHECK: %[[ALL_TRUE_MASK:.*]] = vector.constant_mask [4]  : vector<[4]xi1> 
77// CHECK: vector.transfer_read {{.*}} %[[ALL_TRUE_MASK]] 
88// CHECK: vector.transfer_write {{.*}} %[[ALL_TRUE_MASK]] 
99func.func  @eliminate_redundant_masks_through_insert_and_extracts (%tensor:  tensor <1 x1000 xf32 >) {
@@ -40,7 +40,7 @@ func.func @eliminate_redundant_masks_through_insert_and_extracts(%tensor: tensor
4040// ----- 
4141
4242// CHECK-LABEL: @negative_extract_slice_size_shrink 
43- // CHECK-NOT: arith.constant dense<true> :  vector<[4]xi1>  
43+ // CHECK-NOT: vector.constant_mask  
4444// CHECK: %[[MASK:.*]] = vector.create_mask 
4545// CHECK: "test.some_use"(%[[MASK]]) : (vector<[4]xi1>) -> () 
4646func.func  @negative_extract_slice_size_shrink (%tensor:  tensor <1000 xf32 >) {
@@ -67,8 +67,25 @@ func.func @negative_extract_slice_size_shrink(%tensor: tensor<1000xf32>) {
6767
6868// ----- 
6969
70+ // CHECK-LABEL: @trivially_all_true_case 
71+ // CHECK: %[[ALL_TRUE_MASK:.*]] = vector.constant_mask [2, 4] : vector<2x[4]xi1> 
72+ // CHECK: "test.some_use"(%[[ALL_TRUE_MASK]]) : (vector<2x[4]xi1>) -> () 
73+ func.func  @trivially_all_true_case (%tensor:  tensor <2 x?xf32 >)
74+ {
75+   %c2  = arith.constant  2  : index 
76+   %c4  = arith.constant  4  : index 
77+   %vscale  = vector.vscale 
78+   %c4_vscale  = arith.muli  %vscale , %c4  : index 
79+   // Is found to be all true _without_ value bounds analysis. 
80+   %mask  = vector.create_mask  %c2 , %c4_vscale  : vector <2 x[4 ]xi1 >
81+   " test.some_use" %mask ) : (vector <2 x[4 ]xi1 >) -> ()
82+   return 
83+ }
84+ 
85+ // ----- 
86+ 
7087// CHECK-LABEL: @negative_constant_dim_not_all_true 
71- // CHECK-NOT: arith.constant dense<true> :  vector<2x[4]xi1>  
88+ // CHECK-NOT: vector.constant_mask  
7289// CHECK: %[[MASK:.*]] = vector.create_mask 
7390// CHECK: "test.some_use"(%[[MASK]]) : (vector<2x[4]xi1>) -> () 
7491func.func  @negative_constant_dim_not_all_true ()
@@ -87,7 +104,7 @@ func.func @negative_constant_dim_not_all_true()
87104// ----- 
88105
89106// CHECK-LABEL: @negative_constant_vscale_multiple_not_all_true 
90- // CHECK-NOT: arith.constant dense<true> :  vector<2x[4]xi1>  
107+ // CHECK-NOT: vector.constant_mask  
91108// CHECK: %[[MASK:.*]] = vector.create_mask 
92109// CHECK: "test.some_use"(%[[MASK]]) : (vector<2x[4]xi1>) -> () 
93110func.func  @negative_constant_vscale_multiple_not_all_true () {
@@ -105,7 +122,7 @@ func.func @negative_constant_vscale_multiple_not_all_true() {
105122// ----- 
106123
107124// CHECK-LABEL: @negative_value_bounds_fixed_dim_not_all_true 
108- // CHECK-NOT: arith.constant dense<true> :  vector<3x[4]xi1>  
125+ // CHECK-NOT: vector.constant_mask  
109126// CHECK: %[[MASK:.*]] = vector.create_mask 
110127// CHECK: "test.some_use"(%[[MASK]]) : (vector<3x[4]xi1>) -> () 
111128func.func  @negative_value_bounds_fixed_dim_not_all_true (%tensor:  tensor <2 x?xf32 >)
@@ -114,7 +131,7 @@ func.func @negative_value_bounds_fixed_dim_not_all_true(%tensor: tensor<2x?xf32>
114131  %c4  = arith.constant  4  : index 
115132  %vscale  = vector.vscale 
116133  %c4_vscale  = arith.muli  %vscale , %c4  : index 
117-   // This is _very_ simple but since tensor.dim is not a constant value bounds 
134+   // This is _very_ simple,  but since tensor.dim is not a constant,  value bounds 
118135  // will be used to resolve it. 
119136  %dim  = tensor.dim  %tensor , %c0  : tensor <2 x?xf32 >
120137  %mask  = vector.create_mask  %dim , %c4_vscale  : vector <3 x[4 ]xi1 >
@@ -125,7 +142,7 @@ func.func @negative_value_bounds_fixed_dim_not_all_true(%tensor: tensor<2x?xf32>
125142// ----- 
126143
127144// CHECK-LABEL: @negative_value_bounds_scalable_dim_not_all_true 
128- // CHECK-NOT: arith.constant dense<true> :  vector<3x[4]xi1>  
145+ // CHECK-NOT: vector.constant_mask  
129146// CHECK: %[[MASK:.*]] = vector.create_mask 
130147// CHECK: "test.some_use"(%[[MASK]]) : (vector<3x[4]xi1>) -> () 
131148func.func  @negative_value_bounds_scalable_dim_not_all_true (%tensor:  tensor <2 x100 xf32 >) {
0 commit comments