<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54650>54650</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] Optimise modulo comparison operation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ilinpv
</td>
</tr>
</table>
<pre>
When the result of a modulo by constant is compared against another constant we can sometimes avoid the expensive modulo instructions as described in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87290
For example
```
int
mod16 (int a, int b)
{
return a % 16 == 13;
}
```
with -O2 using this on aarch64 GCC produces better code: https://godbolt.org/z/9K8Gd1Eaf
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtUk2P2yAQ_TX4MtoIQxw7Bx_y0eyhhz32WIGZ2FQELMBJd399x07SrVaVsf0GZt48vUEH897-GNBDHhAipsllCGdQcAlmcgH0O3TBp6x8BpsIX0YV0YDqlaVtUD5QZfxMuiF0ykMKF8z2ggnUNViz0OPvEX2yV3ySzwxx6rKlYlAJDKYuWk301sOQ85iY3DFxotV33ar30yrEniI99R_WOUUwDeH2k-JV11smT9YweWxqseWMHxnf3b-nEKm7uowO_91mG_5YS2h9vgOSV26AiYZ2gJocYAaaie2jrt7fAZBleYqe_GKigrlIHmlBKZncP5OP_-12s3mAlzcBU7K-J4PI3kBMKnbDZg2vhwOMkXzqyEONOS8mGyRHvloTjA4uP6z5oHf7vXk15Td1LkwrzVZuVZFtdtiyar_bLfysOsLbSBOy6e847sO1iVSEEaOa51JM0bVf-pHwSa8omwLnrs_fC8n9hV2m0KY0YSJQrTcVL4YWq64sG8PX_KyNQq3lVmK90dW6KWtZisIpjS7NApkQHm-wUBAmoYVtBReCS8nLmp5qdT7XTVPXZ17XyGvRsDXHi7JuNeuYjShiu0iii5Ho0NmU0-ehSsn2Hhc_Zn415SHE1jrrx2uxdG4X5X8AFG_7_g">