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
2
2
3
3
// This tests a general pattern the vectorizer tends to emit.
4
4
5
5
// 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>
7
7
// CHECK: vector.transfer_read {{.*}} %[[ALL_TRUE_MASK]]
8
8
// CHECK: vector.transfer_write {{.*}} %[[ALL_TRUE_MASK]]
9
9
func.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
40
40
// -----
41
41
42
42
// CHECK-LABEL: @negative_extract_slice_size_shrink
43
- // CHECK-NOT: arith.constant dense<true> : vector<[4]xi1>
43
+ // CHECK-NOT: vector.constant_mask
44
44
// CHECK: %[[MASK:.*]] = vector.create_mask
45
45
// CHECK: "test.some_use"(%[[MASK]]) : (vector<[4]xi1>) -> ()
46
46
func.func @negative_extract_slice_size_shrink (%tensor: tensor <1000 xf32 >) {
@@ -67,8 +67,25 @@ func.func @negative_extract_slice_size_shrink(%tensor: tensor<1000xf32>) {
67
67
68
68
// -----
69
69
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
+
70
87
// 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
72
89
// CHECK: %[[MASK:.*]] = vector.create_mask
73
90
// CHECK: "test.some_use"(%[[MASK]]) : (vector<2x[4]xi1>) -> ()
74
91
func.func @negative_constant_dim_not_all_true ()
@@ -87,7 +104,7 @@ func.func @negative_constant_dim_not_all_true()
87
104
// -----
88
105
89
106
// 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
91
108
// CHECK: %[[MASK:.*]] = vector.create_mask
92
109
// CHECK: "test.some_use"(%[[MASK]]) : (vector<2x[4]xi1>) -> ()
93
110
func.func @negative_constant_vscale_multiple_not_all_true () {
@@ -105,7 +122,7 @@ func.func @negative_constant_vscale_multiple_not_all_true() {
105
122
// -----
106
123
107
124
// 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
109
126
// CHECK: %[[MASK:.*]] = vector.create_mask
110
127
// CHECK: "test.some_use"(%[[MASK]]) : (vector<3x[4]xi1>) -> ()
111
128
func.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>
114
131
%c4 = arith.constant 4 : index
115
132
%vscale = vector.vscale
116
133
%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
118
135
// will be used to resolve it.
119
136
%dim = tensor.dim %tensor , %c0 : tensor <2 x?xf32 >
120
137
%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>
125
142
// -----
126
143
127
144
// 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
129
146
// CHECK: %[[MASK:.*]] = vector.create_mask
130
147
// CHECK: "test.some_use"(%[[MASK]]) : (vector<3x[4]xi1>) -> ()
131
148
func.func @negative_value_bounds_scalable_dim_not_all_true (%tensor: tensor <2 x100 xf32 >) {
0 commit comments