<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/90245>90245</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
scalar/integer miscompile from global isel for AArch64
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AArch64,
llvm:codegen,
miscompilation,
llvm:globalisel
</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 i32 @f(i32 %0, i32 %1) {
%3 = sub i32 %1, %0
%4 = sub nsw i32 %1, %0
%5 = select i1 false, i32 %4, i32 %3
%6 = icmp sgt i32 %5, 0
%7 = select i1 %6, i32 0, i32 1
ret i32 %7
}
```
using this driver:
```c
#include <stdio.h>
unsigned f(unsigned, unsigned);
int main(void) {
printf("%x\n", f(0xe, 0x80000001));
}
```
it should print 0, and this is what happens with the sdag backend, but using the global isel backend it prints 1.
for the given inputs, `%4` is poison. the poison is blocked by the subsequent select but it seems like this is confusing the backend somehow.
cc @hatsunespica
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VNFyqzgM_RrzorkZYyDAAw9ps_kPYwRoa2zWNm3v3-8YhzTtzt5MMpHtI-noSLb0niaD2LHqhVXXTG5htq5zOOHsst4Ov7sZHTJRe5AwbkYFsoYVF8avjF_Ymaev1u9L2hpwJINAhQBW8pGJZjdFxZl4hbudM9ECq1-SC8StAlhxBb_1T5jX5PcFKh8g4z_-BKwSEDWqAJTDKLXHJwLlk108-Z13P1LLCn4KB6KK6Ofw9Y_w0fOI-KgzPxwcPiLVd93q6w8B03LzZCYIM3kYHL2j-6_S6r4WBRmltwGBFa8-DGRPMyv-up-maGZv7gCxC8cisvuyW1a8PLuQCbBIMkw075aG721aHZkQYzEhmKg-WfVqdvN1z8A_d4X5Z8P3T2zytwz_UzQF8LPd9JASJAGlGZIO5OFjlgFmua5oPHxQmCHMCH6QE_RSvaHZi-q3AId-CJO2vdRAHvUBAgopg4f89Fz0aF3yoXc0QGbdgt9n6sz3UTnzyGK15K057chkx91eW_WGA_S_E6mt9_jPhiYc0xFpxQoRFw-a3vBRlrJm_CJ8kPR2wdl-fCOoVLxLswx-M-hXUhLSQTZ0xdAWrcywy-u8zKuqrZts7uq6bEcUSkkpzue-EUVTNQ2WRSVVP6LMqBNclLwU57yJv5OsB563fdsi7-uxylnJcZGkT_Fqn6ybMvJ-w67loqwyLXvUfn81hDiaUFwuF6fmc5mGggmxPwvFRdkBJzSP7YW8sstKWu6vyQ90al3sXDyprpnr4smvfps8K7kmH_wXq0BBY-eV1NIxcSMTcEIHjxQIo7PLt3mI_b4zzTanuzmE1cebJm5M3CYK89aflF2YuO2U0t-v1dm_UYWYJCrhmbjtYvwbAAD__-s-iF0">