<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55129>55129</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
likely arm64 miscompile due to global isel
</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:
```
define i64 @lsr_zext_i1_i64(i1 %b) {
%1 = zext i1 %b to i64
%2 = lshr i64 %1, 1
ret i64 %2
}
```
gets turned into this arm64 by global isel, using top of tree:
```
regehr@john-home:~/arm-tests/error_39$ ~/llvm-project/for-alive/bin/llc test-0101865.bc -o - --march=arm64 -global-isel
.text
.file "fast-isel-shift.ll"
.globl lsr_zext_i1_i64 // -- Begin function lsr_zext_i1_i64
.p2align 2
.type lsr_zext_i1_i64,@function
lsr_zext_i1_i64: // @lsr_zext_i1_i64
.cfi_startproc
// %bb.0:
// kill: def $w0 killed $w0 def $x0
lsl x0, x0, #63
ret
.Lfunc_end0:
.size lsr_zext_i1_i64, .Lfunc_end0-lsr_zext_i1_i64
.cfi_endproc
// -- End function
.section ".note.GNU-stack","",@progbits
regehr@john-home:~/arm-tests/error_39$
```
when %b == 1, it seems clear that the LLVM code should return zero. on the other hand, the arm64 code ends up returning 0x8000000000000000
cc @nunoplopes @nbushehri @ryan-berger @ornata
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVEuTmzgQ_jX40gUFwhj7wGEmk-xldm-7V5cEDSgjS5QkMuP8-m0JYnteqdp1UbK61Y-vn8J058aP0kE_69ZLo5PyLskfkvwu2eXrF8kOe6kR5G4LyTZXzh5_4os_yuJIrITtZQEJq0TCDpDU94sOBBbxywcIwrDKgDfBzo0MizLKjXZxQFoJ-wLFLxGL_tcDW9HVDx_CXM4BvQM_W40dSE3uYojcnsiGOMOgjOAKpEMV3MxO6oFATWB68BbxsxxYHHC0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