<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylVEuP2yAQ_jX4gmz5GdsHH_Jo1F56WKnnCsPYpkvAApxm--uLH9t4I0d7qIRs-GYYvvlmoFbsrUK7cBnhCYV7FJ_dwC8_vqNkjy-Ca1_1FqM4M9g3veDW57IfrN9wAdinRCrJKRH8D2CUH_HZwccO6Ou0ZYk5fZtBUozSsFEKxYWzEt2GeDzFgjRKo-QY3VByvjVJjJIvKD7i2Sn66DS6bLnFkxuXDG53MNkC0y0w2wJ3W2C-BkvsOxbP2DlJDnP2eNw8pntafANKjMWfyoCtepr6PXC0DsylAW1_GsEpzKdy6aIsYqLssOi1UgllJ_zPkK5E-WDYrTSYDM_LMh_5CXENdtDynf_zEs9NlJ-WyUPDboGg9Rhoj-HWA7XAsH3rYdSyHiXJnzZTjpXGBGsiX30NbKBu6xW04UoGbmNhxj6_cHMhlnau-g-ne6xKWJmUxCOD7ZSuvhLNqGJQpN6gRdVZ2xvHa75lLbfdUAdUXdxCiOv7z--1-uVouyU3ZgDjJlkSlqXXVXUT0YI2LIE0zRoSpiTP0zClYUxpRFjqCVKDMNVUtFjCbzyFcHNXMe__GfAqDuM4jMIySrIkK4K8YCRtWFaUNG5o0bgbDhfCRTDGCZRuPV1NIeuhNc4ouLHmbiTG8FYCTIQdQ8utmBbj0-MAN1uKlT3enMNmw69eJGJd2XALEjSxYFxPXh3M8LcXb8qqmlL6Cwxfefk>53099</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir][tensor] tensor.cast + tensor.insert_slice canonicalization generates invalid IR
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```
// RUN: mlir-opt %s -split-input-file -canonicalize | FileCheck %s

func @foo(%arg0 : tensor<1x?xf32>, %arg1 : tensor<?x?xf32>, %arg2 : index, %arg3 : index, %arg4 : index, %arg5 : index, %arg6 : index, %arg7 : index) -> tensor<?x?xf32> {
  %0 = tensor.cast %arg0 : tensor<1x?xf32> to tensor<?x?xf32>
  %1 = tensor.insert_slice %0 into %arg1[%arg2, %arg3] [%arg4, %arg5] [%arg6, %arg7] : tensor<?x?xf32> into tensor<?x?xf32>
  return %1 : tensor<?x?xf32>
}
```

```
error: expected type to be 'tensor<?x?xf32>' or a rank-reduced version. (size mismatch)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFU0uP2yAQ_jX4gmzZYMf2wYc8GrWXHlbquSIwTtglYAFOs_31xY9tspGjlZA9fPP-mDkY8d6gVTqfdIfSNSL7cPDLr5-IrvFZSRubzmNECodj1ynpY6m73setVIBjzrTRkjMl_wJG5RbvA7w9AX8bXeaY47ftNccoT1tjEKmCltljiocsHrQzFtFtdkV0f20pQfQbIls8GWWfjQaTJTMymkkt4HoD6RKYL4HFErhaAst7sMZxqOJZdYGSzdQ9HpyHdnezbcKZ8_hLGrA3T1u_Bc7uA0vtwPrfTkkOU1apQ5SZTFRsZr7uWELFDv9X5HekfFKs7jgYFc-fZUr5ReEWfG_1R_3Pn3gaonI3Cw8DuwSCtUOgNYZrB9yDwP69g4HLw0BJ-XSYSmwsZtgy_RZbED0PrhewThqdBMfKDXN-lu7MPD-F13_IHomGiprWLPLSK2gCdcMKBbKCNCctHidgs_hwd5vFfEiPj6DBMg8ucHsJsMA_XqLequbkfedCs9PqHqU_9YeEm3O4KHX5-MWdNa-Bi3CVzvXgglDQtK6jU5PTgok2W5Upr3lFUsbaSlS8yDNWEchppNgBlGvGSSAa_uAxRJBDN5FsSEpImqV1RgtaVElZCZa3oqhqTlpetWHp4cykSoY6EmOPkW3Gkg790QWlks67m5I5J48aRvaG-Kz3J2Ob78wKbgRUeTRmb8bq_wFCAGQB">