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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Inconsistent results for linalg.generic
        </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:
```
#map = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
module {
  func.func @main() -> i32 {
    %c0_i32 = arith.constant 0 : i32
    %idx0 = index.constant 0
    %c1_i32 = arith.constant 1 : i32
    %alloc = memref.alloc() : memref<16x1x16xi32>
 linalg.fill ins(%c1_i32 : i32) outs(%alloc : memref<16x1x16xi32>)
 linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel", "parallel"]} ins(%alloc : memref<16x1x16xi32>) outs(%alloc : memref<16x1x16xi32>) {
    ^bb0(%in: i32, %out: i32):
      linalg.yield %c0_i32 : i32
    }
    %0 = memref.load %alloc[%idx0, %idx0, %idx0] : memref<16x1x16xi32>
    vector.print %0 : i32
    return %0 : i32
 }
}
```
When I ran 
```
/data/tmp/v0302/llvm-project/build/bin/mlir-opt \
--lower-affine --convert-index-to-llvm --convert-linalg-to-loops --convert-scf-to-cf --convert-arith-to-llvm --convert-vector-to-llvm --finalize-memref-to-llvm --convert-cf-to-llvm --convert-func-to-llvm --convert-arith-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:
```
0
0
```
However, when I ran 
```
/data/tmp/v0302/llvm-project/build/bin/mlir-opt \
--canonicalize \
--lower-affine --convert-index-to-llvm --convert-linalg-to-loops --convert-scf-to-cf --convert-arith-to-llvm --convert-vector-to-llvm --finalize-memref-to-llvm --convert-cf-to-llvm --convert-func-to-llvm --convert-arith-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/eJzsVkGvmzgQ_jXOZQQyBkJy4JC-NNpI28tqpT0-GRiIK2Mj2yQv--tXNiShzau63VVvfXo48HlmvvHMZzC3VnQKsST5B5LvV3x0J23KC1fdVavuc8JXlW6u5RFO_IzgTgitllJfhOrg0-_HP2AwujO8J-mO0J1D6-JeCjM9kjWd_-mOsLTnA5B0D7xthcLXng8kfSFs01DCXqBJwsgI20JE0o_w3gxJPxK663UzSgRSfCB0B9COqo79ACSjPReKsM09ikjZ3RCAsLymrwHziRjhTnGtlXVcOaBA0p13eBiL5o0GU6EafFuYLuIl34qXPMfjUuo62PbYG2zjAMz5eusJJulLsn5L3pL1m3cPiwYpFJdd3AopQSgbnB7sExHbgh7dPHcj-3ZUtl0E7lChEbWvVlitUJ3vkQ3pen2EDvpWzHf53j8Ih4Y7bV7ddcCFMRu44VKiJIxNTt9B8j0p9o-V_Zvsf3CxSyHkH6uKTq5C3cvnk8r16B71nJQM4W8u1FWgbL6Q0hddLvaPftNlr6XmzV0EoUZBXzPr17f5_nuCAIAz1k6beDBCuRvfMhmDbjTqaWbKcR4Xm_SvEyo4guEKnrbvoeGOE3Zw_UDY4UxTygg7SHnuo8Hoz1g7wg7VKGTjf_0mPPg3QaQHByR_IXQXRVJf0ETT_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