<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55178>55178</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
miscompile from arm64 backend
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
regehr
</td>
</tr>
</table>
<pre>
this function (a simple variant of an InstCombine test case) is getting miscompiled by top of tree:
```llvm
define i1 @test14(i8 %X) {
%1 = shl i8 -113, %X
%cmp = icmp slt i8 undef, %1
ret i1 %cmp
}
```
When %X==7, the IR clearly returns false, since %1 == -128 and it's not possible for an undef to be smaller than that.
However, the arm64 backend gives this:
```console
Johns-MacBook-Pro:~ regehr$ llc foo.ll -o -
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 12, 0
.globl _test14 ; -- Begin function test14
.p2align 2
_test14: ; @test14
.cfi_startproc
; %bb.0:
mov w8, #-113
; kill: def $w0 killed $w0 def $x0
lsl w8, w8, w0
cmp w8, w8, sxtb
cset w0, lt
ret
.cfi_endproc
; -- End function
.subsections_via_symbols
Johns-MacBook-Pro:~ regehr$
```
together with a little driver, we can see that it returns 1 for that same input:
```console
Johns-MacBook-Pro:~ regehr$ llc foo.ll && clang foo.c foo.s && ./a.out
1
Johns-MacBook-Pro:~ regehr$ cat foo.c
#include <stdio.h>
unsigned test14(unsigned char);
int main(void) {
printf("%u\n", test14(7));
return 0;
}
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/eJytVd-PozYQ_mvIixUEJiThIQ-XZFe9SpWq6qTeW2TDBHxrbOofyaZ_fceGhN1rT9qqRcjgmfHM5_E3Y66b2851wpKzV7UTWpGEbhmxoh8kkAszgilH9JkwRT4r6w6650IBcWAdqZmFhFYEl7fgnFAt6YWtdT8ICQ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