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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Inconsistent results for affine.vector_store
        </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 private @func1() -> f32 {
    %idx0 = index.constant 0
 %idx1 = index.constant 1
    %c0_i64 = arith.constant 0 : i64
    %c1 = arith.constant 1 : index

    %alloc_58 = memref.alloc() : memref<10xi64>
    %c-211_i64 = arith.constant -211 : i64
 linalg.fill ins(%c-211_i64 : i64) outs(%alloc_58 : memref<10xi64>)
    %43 = vector.load %alloc_58[%c1] : memref<10xi64>, vector<5xi64>

 %alloc_55 = memref.alloc() : memref<20x1xi64>
    %c4351754_i64 = arith.constant 4351754 : i64
    linalg.fill ins(%c4351754_i64 : i64) outs(%alloc_55 : memref<20x1xi64>)

    affine.vector_store %43, %alloc_55[%idx0, %idx0] : memref<20x1xi64>, vector<5xi64>

    %36 = vector.broadcast %c-211_i64 : i64 to vector<1xi64>
    affine.vector_store %36, %alloc_55[%idx0, %idx0] : memref<20x1xi64>, vector<1xi64>

 %idx20 = index.constant 20
    %0 = scf.for %arg1 = %idx0 to %idx20 step %idx1 iter_args(%arg2 = %c0_i64) -> (i64) {
      %1 = memref.load %alloc_55[%arg1, %idx0] : memref<20x1xi64>
      vector.print %1 : i64
 %2 = arith.addi %arg2, %1 : i64
      scf.yield %2 : i64
 }

    %631 = arith.sitofp %0 : i64 to f32
    return %631 : f32
 }
}
```
When I ran ```/data/tmp/v1025/llvm-project/build/bin/mlir-opt --lower-affine --one-shot-bufferize="dialect-filter=tensor,linalg,bufferization" --one-shot-bufferize="dialect-filter=tensor" --convert-linalg-to-loops --func-bufferize --convert-vector-to-llvm --convert-scf-to-cf --convert-arith-to-llvm --expand-strided-metadata --func-bufferize --finalize-memref-to-llvm --convert-index-to-llvm --convert-func-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v1025/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1025/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1025/llvm-project/build/lib/libmlir_c_runner_utils.so``` on the program, I got the result of:
```
-211
-211
-211
-211
-211
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
6.527526e+07
```
However, when I ran ```/data/tmp/v1025/llvm-project/build/bin/mlir-opt --affine-scalrep --lower-affine --one-shot-bufferize="dialect-filter=tensor,linalg,bufferization" --one-shot-bufferize="dialect-filter=tensor" --convert-linalg-to-loops --func-bufferize --convert-vector-to-llvm --convert-scf-to-cf --convert-arith-to-llvm --expand-strided-metadata --func-bufferize --finalize-memref-to-llvm --convert-index-to-llvm --convert-func-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v1025/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1025/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1025/llvm-project/build/lib/libmlir_c_runner_utils.so``` on the program, I got the result of:
```
-211
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
4351754
8.268311e+07
```
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 2d26ef09fc87472cd42ea219c8f9267599872958.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWE1v4zYT_jX0ZSBBGn364EM2XuMN8O6lKNBjQEkjmQuaFEjKSfbXF5TkWE7sdnfbYlF0g0AWyZlnhs98iBK3VnSKaMOyDyzbrvjg9tpsnrjqXrTqPsd8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