<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55287>55287</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
urem+udiv miscompile with global isel on arm64
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AArch64,
llvm:codegen,
miscompilation,
globalisel
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
regehr
</td>
</tr>
</table>
<pre>
this is being miscompiled by the arm64 backend with global isel:
```llvm
define i32 @test1(i32 %0) {
%2 = urem i32 %0, %0
%3 = udiv i32 %2, %0
ret i32 %3
}
```
we want it to just return 0 (or something else that always produces 0) but we get:
```
regehr@john-home:~$ llc foo.ll -o - -global-isel --march=arm64
.text
.file "foo.ll"
.globl test1 // -- Begin function test1
.p2align 2
.type test1,@function
test1: // @test1
.cfi_startproc
// %bb.0:
udiv w0, w0, w0
ret
.Lfunc_end0:
.size test1, .Lfunc_end0-test1
.cfi_endproc
// -- End function
.section ".note.GNU-stack","",@progbits
regehr@john-home:~$
```
cc @ornata @nunoplopes @ryan-berger @nbushehri @zhengyang92 @aqjune @Hatsunespica
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFVEuT2yAM_jXORWOPg-0kPviQ7fZx6PTWcwdsxWZLIAXcNP31FZDEu9uXxwNCEkj69BBmuHR-kg7oFyj1CEfpenM8SYUDiAv4CYHb46YGwfuvqAc4Sz_BqIzgim6hyqp9Vj5m5W3dlOlX6vsxsQY8SI0gKwZZXXp0fp2xXTyypsxYC9n2IalCYBG_eoTZ4hEWpTdpX7SqpDXI7zct9lrLor_Jqqt328dXbqbjGeHMNWl78AaeZufD5dlqKOn2zlhw5oiEFCGEyiHhwj1wdeYXBydrhrlHBzEWMXug50b0CzIvjVkccbIExZOZdD7Rw0Fz-zZjNSjVw8GYQinIDeSQJ6TzgDTk-ZHbfqK4Y0pusLeFxx9-OR0oebRnjKWXiFiE4T1FREwD_P3L2Dv6ySQ84Cg1HGbde2k0pPzd3zsxruSoiXxmxF9OeLNBSaFQb9eTThJU-3_Yf-nGvW7uJvqD_OI8t57Q76_sqy5rhCjKZ3XZhiqh7Rzr6L7epJTpRBcfg5tfqMpf3C6c_Pk8HHiml__BLeIvTv0_xNd4v6UmewlX9AGvjJDXQhuPxftPn3OCoP8aEkwoh5UluMn-KKR3_y-4P1ZoWvs-4G6s5p4HSs_anJQ5UaXTyV64zgXaEW0UitlNZEWGw88J9UjysY0tz789zTQAiPrAvSPSnWTPV0NXDW3V8pWXXmEXGj5jD7Gjlyn027wBqsFY_qvZqm7y_uRCNBG-kXRnUdBVOsQBlLac8HgiAOkonZvREdE0bLddTR1n7brZNoiHDQrRsAMNkH5T1zVualGWm5Xiglq-y5oHgvc6Bcnifk-tSE3IrmOHRXvVvjcDwa0X_j0WHhN456eY4gglXvO4kh0rGSubsllvyjo0csvavsJhWO_WVb3eEYB45FIVwVRh7LiyXQxPzKMjIT3m3SLkzlFnIkbX6X0--8nYLlXDKgLRRRR-AdIQt6I">