<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55644>55644</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
miscompilation of smul.with.overflow.i2 by arm64 backend
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AArch64,
llvm:codegen,
miscompilation
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
regehr
</td>
</tr>
</table>
<pre>
here's a function:
```llvm
define i1 @f(i2 %0) {
%2 = call { i2, i1 } @llvm.smul.with.overflow.i2(i2 %0, i2 -2)
%3 = extractvalue { i2, i1 } %2, 1
ret i1 %3
}
declare { i2, i1 } @llvm.smul.with.overflow.i2(i2, i2)
```
clearly `f(1) -> 0` because you can't get an overflow when multiplying by 1 but using this driver:
```
#include <stdio.h>
unsigned f(unsigned);
int main(void) {
printf("%u\n", f(1));
}
```
we get:
```console
Johns-MacBook-Pro:~ regehr$ llc foo.ll
Johns-MacBook-Pro:~ regehr$ clang foo.c foo.s && ./a.out
1
Johns-MacBook-Pro:~ regehr$
```
cc @ornata @nunoplopes @ryan-berger @nbushehri @zhengyang92 @aqjune
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVMlu2zAQ_RrqMrAgkZIVHXRw4uRQoEB_gaIoiQlNulziul_foWRnaYI2AAFxtjdvFqq3w7mbpZOENh44jNGIoKwhbEeKPSl2ZFusR-vnw6oa5KiMBFUCqYqR0BtFgdC6ILQF0tyuTpBUqGd7EFzrZABFCb1b4pp9ik2QuT9EnZ9UmHP7LN2o7SlPfq-gGEFhg6r2DTJbkOWv4LgIz1xH-UkGJJDE8hrnZFhsGH4prtlfLpfChObuM6T_cl1pvnB86dpbeKEld_oMqE5dK1O_NoTdQ3KEXgoevYSzjdgxg_MIMCFhbuCaDE6zNIAcgjrqszIT9GcooY8Bok9imJWHwSn0_zjAi0iZMkLHActkdz4MyuYzknhLNBqvJiMHSDSvQqqN3b51UybAgSukevNs1fDX-I8O7QmAUOxLHUl9Z5brHVyrfwf5MorPWneSqRcfaxLWeKvlqv1mZ-M337m4tfZp88PZ5N_c49gnOTtCK9BawGhtrvVXI3AhsK8pZo30uD1bPJAT-sBzG8OKVH4V8F_7IdKiWWd44OlmorFHbY_SJ8mdudn00k3SLcY--hkxVRJ-415MaJ9amkT-8zEamQ0dG1rW8iyooGV3UF7Yw1Fpnh442BE-Xee0U9wdthX0XDxJM2TR6W4O4ehTMfQBz4Qxsc8RDoXlx7B-NkdnH6UIKCrvo_R4qettVWVzVzA-jFXBCknZ2NzU26KkTTn2TSsHVvYs07yX2nekvsU1ueTGjLudE_O2uqwOfpZ8bCfsgE01r_r39SV9vc9URwtKi5qygrKqavOhbZuikFKUrZBjXWG7JC6xzpcHbt2UuW4ppY-TT-9e-eBfjdwvr0EuNBGfxzBb163zzZaiu6XiP3Xfi3M">