<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60968>60968</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR] Invalid output caused by `-scf-for-loop-canonicalization`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
sweead
</td>
</tr>
</table>
<pre>
Hello, I just ran into a bug. When using `-scf-for-loop-canonicalization`, I get invalid output.
IR:
```
//mlir-opt -scf-for-loop-canonicalization core-ops.mlir
func.func @affine_apply() {
%i = "arith.constant"() {value = 0: index} : () -> index
%j = "arith.constant"() {value = 1: index} : () -> index
%a = "affine.apply" (%i) { map = affine_map<(d0) -> (d0 + 1)> } :
(index) -> (index)
%b = affine.apply affine_map<()[x] -> (x+1)>()[%i]
return
}
```
Outputs:
```
module {
func.func @affine_apply() {
return
}
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE-Pmz4Q_TTDZQRyBkzIgcNm-UW_SK0q7aXHyoCTeOXYCNv7p5--wrBJVu1WXQkZbM-89wa_sXBOHY2UNfAt8CYRwZ_sWLtnKUWftLZ_rf-XWluge9zjY3AeR2FQGW9RYBuOGX4_SYPBKXNEKFnqukN6sGOqrR3SThhrVCe0-im8sgZKNiMdpUdlnoRWPdrgh-AzYA2wu3ncP0C-fE4p8zNPaQe0O2s1pnbw-Hc67OwoUzu4bEqYAQ7BdNk0IBRMHA7KyB9iGPQrUAW0QVhv50BEIK4Q8gaBSIzKn7LOGueF8UB0DX8SOsgYxyC_Q2V6-QLrBqfJEpVC_t-yccV-_BT26lPY4oIdK8yWCmlO4mqBx7MYYuTyI85igPweqOrZBTrOEGiLK6BNXJkFvNFNhNUs4CbnbeFGVHtDNSv6jXdK4NsX4M0F6AVouzBfAmIJvFmwR-nDaBZ_rJs_-uZbNJn7yFZn2wctbw__Ez7BdwoQrxo-EJP0dd5v8o1IZL0q12sizlmVnGpZHVrJi1XJSs6LjnOq8kPRbfqqy8WqzBNVE6OcERVszSuqsg0vqrIQed4WBfGuhILJs1A60_rpnNnxmCjngqxLtimrRItWahebncjIZ4ybk-N4k4z1lJO24eigYFo5764oXnkdb4mvX_YP0_Hs33UvdiI42WP7-k-XQBJGXZ-8H-KBxJY-Kn8KbdbZM9Buol1e6TDaR9l5oF0U64B2sZhfAQAA___bm1dp">