<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65120>65120</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missed optimization for bitset based equality
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bmaurer
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/nTseoW9z1
```
bool test(unsigned long long x) {
auto mask = x & 0xf;
return (mask == 10 || mask == 1 || mask == 2);
}
```
clang generates:
```
test(unsigned long long): # @test(unsigned long long)
and edi, 15
cmp rdi, 11
setb cl
mov eax, 1030
bt eax, edi
setb al
and al, cl
ret
```
the comparison against 11 is unnecessary given the range of the mask operation. GCC emits shorter code:
```
test(unsigned long long):
and edi, 15
mov eax, 1030
bt rax, rdi
setc al
ret
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE2P2yoU_TXXm6uJANuJvfBiJpHf6u2e9NZgbhxaDCngaWZ-fWUyH03rjtpKFgjOuR-cI18ZoxkdUQf1A9SHQs7p5EOnJjkHCoXy-qk7pXSOUN6D6EH0o9fK27TxYQTRP4Po3X-R_P_tMwd2AHYPW_by5aPy3mKimEA0s8vVNFrvxutyAdEi7B6uZEREOSePk4yfEcoDXhDEFtnlCOV3nEBpDg5BNK_EhcsZwm4Puz3e3K5dChDtW0bYHVZbv66DlW7EkRwFmSgLsUb-5RNzpXsEUSJU7EPa2_uyDk7nnbQBsUde38LDdMbwAvFbKFJSmWJv7yf_eM0oLzmMleyWoNIrthRdzSntepfSLmFvFQOlDyRNJ8LBT2cZTPQO5SiNiwk5RxNxdo4GilGGJxzNIzlc6EG6kdAf8yE76c-LIca7Df6z3yNNJkWMJx8SBRy8pnen_sKvP_Lid4QNVyysCDusCfuzgoXuSt2WrSyo49u2rERVcVacuoEzwSrV6qHZ6aNqa8abekdalrzSDRsK0wkmStaUjLcV42xTq1o1raStYEfetBVUjCZp7Mbax2n5tQsT40zdtuaCFVYqsjGPCCEcfcUMghDLxAjdEnOn5jFCxayJKb5nSSZZ6v41MZJGf05mMs_ZMzz6gMqkSAmVXFD6Mktr0lMxB_vjyDHpNKvN4CcQ_ZL7Zbs7B_-JhgSizx1FEH3u-FsAAAD__8wJWzg">