[Mlir-commits] [mlir] [mlir][Vector] Infer mask and pass_thru types for maskedload/store (PR #131482)

Kunwar Grover llvmlistbot at llvm.org
Wed Mar 19 06:54:40 PDT 2025


================
@@ -1348,55 +1348,58 @@ func.func @store_memref_index_mismatch(%base : memref<?xf32>, %value : vector<16
 
 func.func @maskedload_base_type_mismatch(%base: memref<?xf64>, %mask: vector<16xi1>, %pass: vector<16xf32>) {
   %c0 = arith.constant 0 : index
-  // expected-error at +1 {{'vector.maskedload' op base and result element type should match}}
-  %0 = vector.maskedload %base[%c0], %mask, %pass : memref<?xf64>, vector<16xi1>, vector<16xf32> into vector<16xf32>
+  // expected-error at +1 {{'vector.maskedload' op failed to verify that all of {result, base} have same element type}}
+  %0 = vector.maskedload %base[%c0], %mask, %pass : memref<?xf64>, vector<16xf32>
 }
 
 // -----
 
+  // expected-note at +1 {{prior use here}}
 func.func @maskedload_dim_mask_mismatch(%base: memref<?xf32>, %mask: vector<15xi1>, %pass: vector<16xf32>) {
   %c0 = arith.constant 0 : index
-  // expected-error at +1 {{'vector.maskedload' op expected result shape to match mask shape}}
-  %0 = vector.maskedload %base[%c0], %mask, %pass : memref<?xf32>, vector<15xi1>, vector<16xf32> into vector<16xf32>
+  // expected-error at +1 {{use of value '%mask' expects different type than prior uses: 'vector<16xi1>' vs 'vector<15xi1>'}}
----------------
Groverkss wrote:

Actually, no we cannot emit a better message than this. This is failing in the parser. The parser when reading the whole IR, is finding two possible types for the mask: `vector<16xi1>` and `vector<15xi1`. This is the equivalent error message you will get if you had passed the type `vector<16xi1>` to `vector.maskedload` but the type of the actual value is `vector<15xi1`. 

This is actually now producing an error message for something different.

Before, we could have two problems:

1. Type of mask passed to operation is wrong
2. The actual type of mask is wrong

With this patch, 1. is not possible anymore so the error is for 2.

This is actually better, because there is no possibility of writing the wrong type here anymore.

https://github.com/llvm/llvm-project/pull/131482


More information about the Mlir-commits mailing list