<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/84718>84718</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            miscompilation of trivial but non-canonical arithmetic by AArch64 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>
    this IR:
```llvm
define i32 @f(i8 %0) {
  %2 = add i8 %0, 0
  %3 = icmp ugt i8 %2, 1
  %4 = select i1 %3, i32 1, i32 0
  ret i32 %4
}
```

is currently getting lowered to aarch64 like this:
```
Johns-MacBook-Pro:build regehr$ ~/llvm-project/for-alive/bin/llc foo.ll -o -
        .section        __TEXT,__text,regular,pure_instructions
        .build_version macos, 14, 0
        .globl  _f                              ; -- Begin function f
        .p2align        2
_f:                                     ; @f
        .cfi_startproc
; %bb.0:
        mov     w0, wzr
        ret
        .cfi_endproc
                                        ; -- End function
.subsections_via_symbols
Johns-MacBook-Pro:build regehr$ 
```
of course this isn't correct -- for most values of %0, this function should return 1

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE2L6zYU_TXy5uIgy3ISL7xIZl6ghUIpb9GdkeVrWx1ZCvrIdLroby-WM868vsdjQgjR5ejo3HM_hPdqNIgNqc6kes5EDJN1jcMRJ5d1tn9rwqQ8_PIHKU-EPhN6Inu6frW-zWuox0EZBFUyIJwOhB3VEQirKGE1kMN5RcESYkDKZxB9DxvkCegHQJkASs5XiGO4o9iCKj6geEJ51CgDqCJdXDCLhOL9z0brMKziWMXvSRye_5fN_Zh-lQcZnUMT9BuMGIIyI2j7ig57CBaEcHLac9DqBWHx53tz1uOvdjI-_03Is7Uv-e_OkvLURaV7WB0mjMO_hF0WK_Ors3-hDIRdButyodUNCbt0yiSAhMHandaQW8jfxdY7jzIoawit2_brlz-_EvbUtgH_DoQ9ORyjFo6wp2t02Crjg4sJ7h8ESU57Q-eVNTALaX0ym38ozIIbte308swAP_2Q8gx5DmcclYEhmvQeDA-iKxNajYtitgbbgZSnn5N-4E4NtpHJQbU-CBeuzsp7eAGxqut29FEWWs_2Rmj9mvrt9R-3xR2Gb-nQ9A-yT8l6ZP3F9FvOK8HOx-5eI9_elGj929xZ7T_fHz9sLDuAtNH5tf1AeUPYIYC0zi0TkecwWAez9QFuQkf0YIdt3NKVrTR-sjE9GKIz70OW9U3Z12UtMmyKQ0GLkvFin00NPxxLrArO6mqQuMeOVgzlgeKe78XQiUw1jDJOy6KgnO-r_a6qeC-KShS07pGzI-EUZ6H0bmn6nXVjpryP2Bz5oThmWnSofVpHjHVCvqDpSXk6ndLEEbZsAsJY2j3lSdoeRzRbeFZe2vmqtEgVYGzZaa5J49XF0RNOtfLBP94OKmhsvr23eBWcuimhoYsBjDW5FMYaJYUG4VSYZgxKQvcGd2Fwl5pFp5sphGtaCexC2GVUYYrdTtr5Pujfz3sywBN2SR78FwAA____N5qv">