<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67916>67916</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] `!a == (a < 0)` is not optimized
</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>
Consider the following functions:
```cpp
int foo(int a)
{
return !a == (a > 0);
}
int bar(int a)
{
return (a < 0);
}
int baz(int a)
{
return !a == (a < 0);
}
int qux(int a)
{
return (a > 0);
}
```
Both Clang and GCC can optimize `foo` to `bar`. GCC can also optimize `baz` to `qux`, but Clang cannot.
https://godbolt.org/z/exvTE8Gn7
https://alive2.llvm.org/ce/z/LGvASc
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycU12PmzAQ_DXLyyrI2OCEBx4SOKJKfWv_gA0G3Dp2ik1yza-vIFz6oZ56PQmJBc_Mjsde4b3urVIFZAfIqkhMYXBj8XUjxtFdfSRd-70onfW6VSOGQWHnjHFXbXvsJtsE7awHtgdSAdkDJ_enOZ_vf7QN2DkHdDdXAmi-IreHe4GIowrTaBFoIhBYBaxCoLu5fkIyM9jhhVStxUNbivFt2ote-Qa92zu9_lv72_T8H15f3ftLxr_KH1wYsDTC9ihsi8eyxEZYdOegT_qmEDiZT4ETDG7-mGPjJH4AhfHuN_ScwwM9G-cEaIlyCmubRljrQnxvP4RwXm4BrYHWvWulMyF2Yw-0vgGt1fPl89PuaLd_gwujL4rGxlxOK6VRK-_j8bL_1ERtwdqc5SJSRcJznvA8zbNoKLqua8hO5oTnvJGMsjzbJrtOikxI0nAR6YISyhJCkiRNEpbFIk9TlnZ0yxLWSiIgJeoktHl0j7T3kyr4Nk94ZIRUxi-jQalVV1wWgdJ5UsZi5mzk1HtIidE--J8qQQezzNQH60PpTlJbBVmFS4yvXR1OUHu0LjxOoo2m0RR_pKvDMMm4cSeg9dxwfW3Oo_uimgC0Xmx6oPWyjR8BAAD__7IIGGc">