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

    <tr>
        <th>Summary</th>
        <td>
            Wrong type inference for 'memref.store' 
        </td>
    </tr>

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

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

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

<pre>
    code :
```
//example.mlir
module  {
  func @main() {
    %cst_4 = constant 1.000000e+00 : f64
    %2 = memref.alloc() : memref<2x3xf64>
    %c0 = constant 0 : index
    %c0_5 = constant 0 : index
    memref.store %cst_4, %2[%c0, %c0_5] : memref<2x3xf64>    
    memref.dealloc %2 : memref<2x3xf64>
    return
  }
}
```
I tried to run `mlir-opt -convert-std-to-llvm example.mlir` and got the following error:
```
example.mlir:7:5: error: 'memref.store' op operand #2 must be index, but got 'i64'
    memref.store %cst_4, %2[%c0, %c0_5] : memref<2x3xf64>
    ^
example.mlir:7:5: note: see current operation: "memref.store"(%0, %1, %2, %3) : (f64, memref<2x3xf64>, i64, i64) -> ()
```

It looks like the lowering pass covert the type of`%c0` and `%c0_5` from index to i64, while the operand `memref.store` is not passed to adapt this change



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VM1ymzAQfhpx0cCAZMAcOCRxOtMn6DHDzwJKBGIkkThv35UA184kaS_1yIj90e63u5-oVfteNqoFSvgdiU8kviNZvK1VZD9wwbkaZwnRKIVe9aNqFwmUkvx-VVDaLVNDySEeKzERdiSsuLaiK0sbY58OmOtEGzUZW02WJlHsf0DYfRw7HLTLDjenmD8xwqihiyopVbOHR-dVTfgDO_OzO8kfb1PGt_nWFGJq4fzB7yn9B88NhbFKw6Uiwh48TpLe-0ib7EKS9PQVTJ_4Y-AWfIF72X-pT4Nd9LTLJD9tQ7u83A7zJ7VaQEutonqZKOrdQEM1Wxpi2a-gbWhsG1oVSvk60puxZzGtppb2ylI7AO0U4nwTU09Ba6W_4s9NCH6X4z91Ze2HsND8uqcoUjXjAu2yEcYZHRdjaQ3bKLC39WI9DnQW2BGW_5f5XNEjffy-mklZcLsBoM2iNSB9fAlWqGmtkt1WyTyF0x1KcoG47nynN7o5NKj9DCGqxWr1W0FDx6v1dnx-nVceWCqVejFUihfw08RRgnbDnCtj8Ao4KniDfZ-Bqs4F8J3bWLDL2EDUdFqN63QctTZEb4OQa_DLMJFv103Ak8K43vmsKy-rtppdZjQ0QzX1cI17fQZQJlmWsCznBQ_akrcFL6rACiuh_KUVVuFRi6kDnETjuKo_41mwaFkO1s7Gsdd_6Hphh6WOGjWi4O7AtoWzVs_QWBSFMQsYfElznsTBUCZFAQXkLIGsTvIiTxNEBIc2T47HmrNDIKsapCkd-9JTIEoWMxYfGU_SuEh5lBVJlWacd8eO1UXa4ScU8BsqI5c4UroPdOkx1Etv0CiFseaPEVsn-glgj18tdlC6tM_L2_AeeLSlh_ob28-xzQ">