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

    <tr>
        <th>Summary</th>
        <td>
            [AArch64] Optimize compares with multiple uses
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:AArch64,
            missed-optimization
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          SamTebbs33
      </td>
    </tr>
</table>

<pre>
    This example has multiple uses on the AND:
```
int and(int num) {
    num = num & 0xff;
    if (num > 1)
        return call(num)+1;
 return 0;
}
```
and becomes
```
        and     w0, w0, #0xff
        cmp     w0, #2
        b.lo    .LBB1_2
```
If this example used a tst it could start a cycle earlier, not having to wait for the result of the and, like in
```
int tst(int num) {
    num = num & 0xff;
    if (num > 1)
        return call(0)+1;
    return 0;
}
```
which becomes
```
        tst     w0, #0xfe
 b.eq    .LBB0_2
```
https://godbolt.org/z/6Tnz4szYn

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8lM9v6zYMx_8a-kI0kCn_iA8-JM0CDBi2w3rZaZBsOtYqW5klN23--kFOujRbi_dOTwhCU_yCpPiBpLw3h5G5hnwL-S5Rc-jdVP-uhifW2kuZaNe-1U-98civajhaxl55HGYbTHRmzx7diKFn3Py6A7kBsQOxgUJcf4trxoBqbIHW8WucB6AKodxeoogY9xDk7mKpQPHadSA_CEyHQOuL7CdMgapbLK6JwzyN2ChrL7qooG16S3JViH93oNx92q0aW9TcuIH9p_H3klEX10kAPV7_geTS-p2wGY4fhECS7uN6ZV20q1-22_RP-rTozx2Gjxhmzy0qDD6gCdi42bbog5oCKmzeGsvIarKGp1hydAF79WLGAwaHJ2UCdm5aqE3sZxvQdYu3QHpEa54Zzfgly-DDj2Mp_kfyJvk2zFNvmv67cMZR3lESrx1fJXrFf78TEl8Q6kM4-ngDaA-0P7hWOxtWbjoA7c9A--JpPGf-_Md1rElby7aSlUq4TosyzcqUqEj6uqFcdSSysmWdqaKQZVvoKtdyzXrNKk9MTYIopbRKSymzYlW2meJMVlWxFk2nBWSCB2XsytqXIXaQGO9nrvMqr9aJVZqtX648kVbNM48tyM1mMzV9kQER0CMQDcZ7bh_cMZjBnFUwboyxfJdMdcz7oOeDh0xY44O_VQom2OU9ec-X7_C3Sw7Gxg1HNbHHkwn9_SuSzJOt_zNCE_pZrxo3AO1jgat5OE7uL24C0H45lwfaL0f7JwAA__-_61kP">