<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/129415>129415</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Inconsistent results for vector.mask
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          wangyongj1a
      </td>
    </tr>
</table>

<pre>
    I have the following MLIR program:
test.mlir:
```
module {
  func.func @main() -> i32 {
    %c1 = arith.constant 1 : index
    %0 = vector.create_mask %c1, %c1 : vector<3x3xi1>
    %c1_i32 = arith.constant 1 : i32
    %1 = vector.broadcast %c1_i32 : i32 to vector<3x3xi32>
    %2 = vector.mask %0 { vector.multi_reduction <add>, %1, %1 [] : vector<3x3xi32> to vector<3x3xi32> } : vector<3x3xi1> -> vector<3x3xi32>
    %3 = vector.extract %2[0, 0] : i32 from vector<3x3xi32>
    vector.print %3 : i32
    return %3 : i32
  }
}
```
When I ran 
```
/data/tmp/v0302/llvm-project/build/bin/mlir-opt \
--canonicalize --convert-vector-to-llvm --convert-arith-to-llvm --convert-func-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v0302/llvm-project/build/bin/mlir-runner --entry-point-result=i32 --shared-libs=/data/tmp/v0302/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v0302/llvm-project/build/lib/libmlir_c_runner_utils.so
```
on the program, I got the result of:
```
2
2
```
However, when I ran 
```
/data/tmp/v0302/llvm-project/build/bin/mlir-opt \
--lower-vector-multi-reduction \
--canonicalize --convert-vector-to-llvm --convert-arith-to-llvm --convert-func-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v0302/llvm-project/build/bin/mlir-runner --entry-point-result=i32 --shared-libs=/data/tmp/v0302/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v0302/llvm-project/build/lib/libmlir_c_runner_utils.so
```
on the program, I got the result of:
```
1
1
```
The above two results seem to be inconsistent. I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused these results.

My git version is b6d5fa05ada6e51ede32c62ff47f046ca5085d28.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVk2P4zYM_TXKhbAhS_5IDj5kkw0aoHspCvQ4kC3a0VaWAklOJv31hexkxrMzu0Bb9FIUiJ2Eoh4fyacP4b3qDWJNik-k2K_EGE7W1Vdh-ps1_ddMrBorb_URTuKCEE4IndXaXpXp4cvPx1_g7GzvxED4ltBtQB_SQSs3_yUlvX_odrBy1Aik-kToFqAbTZvGF5CcDkIZwtaEbSAh_DMozl4cAQgr2gwI34NwKpzS1hofhAkQjVtQRuLzqyudPC_YBuvS1qEI-DQI__sMQ9juBW979yJ8x5_5s8oI_7wM-TTR-G5Yzl6ds2XQxlkhW-HDG5hpBgT7TVDO3kRlS6AHbRqL8WIcdVBPDuXYBmUNEL4TUkaQObVHihnMLf0g0Snmd6gAqT6aEmsz9-aH9PmSPj4HJ9qpCowUn2gkRh-MYjE6Z4cf4N1hzk6Z8ABf1t1hGJ15P0KqfdTe_F4o8LcTGjiCEwa-GSHsIEUQhB3CcCbscKGcMsIOWl-G5OzsV2wDYYdmVFrG76jWQ5R5Ys8BSLEjdJskrTDWqFZo9QdCkrTWXNCFZE4jCTaJcIuBSVYf2OOqWJgdtta0SmMyGocTukyivDy8LDcgVWz6383CjcaggyRBE9wtOVtlQuLQjzoQvo-tShJ_Eg5lolXjCd__xVhaNfM7hnuawz2NQWmfekvY7h_Bte8A33bXmmnfemxUbAdH6G2YjHOSYLv3Gxa7P0vbT_aKF3QR4_ovq0nbK7qHeKZFnywW_f-S-y9KLrs_S9uvJwTR2Hj4Xu19sgePOMQdvEFQJp5Mygc0IYUjYdUAxgbwo0NQXYwZf3gQ5gbN2IMyMNwe3MC6uxNcnTU9jF70CHY2zYHPwnv00IrRo4x2_8jCp5Et3X65Qa8CXND5KE_loSll0QlaCClKL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