<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61847>61847</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR] Arith canonicalization turns comparison result into -1
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Kuree
</td>
</tr>
</table>
<pre>
Using the commit 46a384dfbe11545b200611e471cb4242d1295589
```console
$ cat test.mlir
module {
func.func @main() -> i32 {
%c1_i32 = arith.constant 1 : i32
%c0_i32_3 = arith.constant 0 : i32
%0 = arith.cmpi ne, %c1_i32, %c0_i32_3 : i32
%1 = arith.extsi %0 : i1 to i32
return %1: i32
}
}
$ mlir-opt test.mlir --canonicalize
module {
func.func @main() -> i32 {
%c-1_i32 = arith.constant -1 : i32
return %c-1_i32 : i32
}
}
```
Is this expected semantics?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUk89upDgQxp_GXEog29gYDhw629tStLuXleYcGVPdeGTsFjYzmXn6kUkn3ZlODoOQwX--Kr5fUTpGe_KIPZEPRO4LvaYpLP0_64JYDGH80X-J1p8gTQgmzLNNIBpdt2I8DsiYFHLglDaMoVDMDIILPjLeSdl2hO4J3V3Ghr7cJvgYHF5WuQCjEySMqZqdXV6W5zCuDoGoh5c5AMBx9abKAxBBZ2094S3hHZSk_htszd-fzhfh0rCnbaveg15smqqcPWmfgAGpd1l3r6FZ81R_pKK_qQiX9PbcfLbgkfC_rslfJ9eoH6dlN3HwOUX7GnwHlkEK96IF07r4TXsXlKj9hfDbyxvwzLkM5xvqUJZG--Ct0c7-xM-K8AclyI7LT-GXH9C_urkK36G-d_T6S90afIyQJhsBn89oEo4QcdY-WRNJfSjGvh67utMF9qxpKesobWQx9e1RKTYKpdQgBdNK0EEyqUTXCXY0qArbc8prWteUSa6ErNQgxwa1Zq2hAw5HIijO2rrKuW9zFZZTYWNcsW9YK1Th9IAubi3GucfvsG0SznPHLX3WlMN6ikRQZ2OK1yjJJrf15n__Pv5P5B52GSXclEsnGzxkeDE36FkvNgYPC8bVJbA-BShZsS6un1I6R1LvCD8QfjjZNK1DZcJM-CHnuzzK8xK-okmEH7avjIQfNhe_AgAA___LyCun">