<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65073>65073</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`a ne/eq (a ne/eq 0)` pattern is not simplified
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Such a simple pattern may already be mentioned in some existing issues, but I couldn't find a duplicate. (If there is, please feel free to close this issue as duplicate.)
https://godbolt.org/z/rvEaKjE4E
```c
bool f1(int a)
{
return a != (a == 0);
}
bool f2(int a)
{
return a != (a != 0);
}
bool f3(int a)
{
return a == (a == 0);
}
bool f4(int a)
{
return a == (a != 0);
}
```
GCC
```asm
f1(int):
mov eax, 1
ret
f2(int):
cmp edi, 1
seta al
ret
f3(int):
xor eax, eax
ret
f4(int):
cmp edi, 1
setbe al
ret
```
Clang
```asm
f1(int): # @f1(int)
xor eax, eax
test edi, edi
sete al
cmp eax, edi
setne al
ret
f2(int): # @f2(int)
xor eax, eax
test edi, edi
setne al
cmp eax, edi
setne al
ret
f3(int): # @f3(int)
xor eax, eax
test edi, edi
sete al
cmp eax, edi
sete al
ret
f4(int): # @f4(int)
xor eax, eax
test edi, edi
setne al
cmp eax, edi
sete al
ret
```
FYI
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110293
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVk1z4zYM_TXUBRMPBcpydNAhiaNOpseeeupQFCxxS5EuSeVjf31HlvyRNPZ60-V4DEokHt8DaAMyBN1aopIt79lyncghds6Xf99I791LSGrXvJV_DKoDCUH3W0OwlTGSt9DLN5DGk2zeoCboyUbtLDWgLQTXE9CrDlHbFnQIAwWGD1APEZ5AucE0luEqwkbbBiQ0w9ZoJSMtgOHt0wZiR55A75y2hmQg2BAZ2HgiiA6UcYEgdjpM6CDDCQjDAhhfM343fXcxbgMTdwwrhlXrmtqZuHC-ZVh9Z1j550f5-7fH7HF2yvn0UdNz7ZyBTcrwVtsIkmEx71vdTxPwFAdvQQLDlIn1KEICE-txzsf94n7vsj4lNiHjBWSAM-DT_Mfg4lrwie3PMc--An6R-T70p2f99vDwYVWGfnqzz8oO7O548jh697yzJF_Ha5S-X_UUZwg8D6H67QTR6E8gAkUJ0pzDFedxX50_pTaaw0WavbP_waomgCOxA-anwX0w0rbXhRcYCmAZP317nax5RArxhPhopvVAcaT8n2AelM6AB4ejVvu51vdZhR-NvTK8oOynVZ0jeSLuamGXb9eBv_jVmTny-WqC6IKI7EtJyj6K_AXq3kf7KlnX_8aqP58-LURKLVo7zIWoHtrv2hjJsAqde_mrHtqFajUTlW6YWKcpx0IkTSmaQhQyoTLNCyGQr7JV0pV5rmSRp5ksNjxFoVDe8poT5bnYFEo1iS6Ro-C3WKTZEnG1kLRcLVVdyLxoVJ6uWMapl9osjHnuR07JrrKW-ZKvRGJkTSbs2gRESy9T2WWIY9fgy9Hnph7awDJudIjhiBJ1NFSO_ypgiWFF_0x1YP-wKwQ5P_QVOoB1ceo29EZTkwzelB8ip2M31AvleobVeNJsbrbefSMVGVb7pqPa8f83AAD__24MUnM">