<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60854>60854</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Generate better code for X == Y ? 1 : 2 on x86
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:X86,
missed-optimization
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kazutakahirata
</td>
</tr>
</table>
<pre>
Compile:
```
unsigned sel(unsigned X, unsigned Y) {
return X == Y ? 1 : 2;
}
```
I get:
```
31 c9 xor %ecx,%ecx
39 f7 cmp %esi,%edi
0f 94 c1 sete %cl
b8 02 00 00 00 mov $0x2,%eax
29 c8 sub %ecx,%eax
```
We could generate:
```
31 c0 xor %eax,%eax
39 f7 cmp %esi,%edi
0f 95 c0 setne %al
ff c0 inc %eax
```
saving 5 bytes.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykU91upDwMfZpwY3UUHH7CBRdtR_Ppe4JtL00wTLZARiRU0z79igFmq92Z3YtFUYwVH59jxyHvbTswlyJ9Euk-oikc3Vi-0ecU6I2OdqRAUeXqj_LZ9SfbsVCPQu6F3PZMruviTsMlXw2eO4H66r4IfIar9yqwAJE_LRiAkcM0DvACQu2F2sMrCHWAGIR6BBRqjRP5_ibnsv8PLYc_iwNQMZgCbn5nN4LAlM1Z4PP6s6EKaPLbKNOfZjPHe7sCa7sBZQNFAiYGz4GXMNNth5UGiSDlur5-vXtfsibyjGtW2uRgAUbfVuOnalNzLWPD_daLxX5jMG7qamh54JHCX-53aaG838KVnn6l_8cupjOp5zDwJYyuXWyau3LsYL7IuT85nt7t0EIK1Udgv4vqUtWFKijiMs7yLE91FufRsSStTUIqpkSTplwixZKaIkZNMZukiGyJEpXEWCPGWZrvdJLoJJV1ljVoVK5FIrkn2-267r3fubGNrPcTl5nUaRJ1VHHnLy8RsSLzxkMt1OOLzgQuU4C99Z7rB3cKtrefFKwb5rN0H43lnPOhmlovEtlZH_xPlmBDx-V_6w1DxSHwCMbVDI0b77w7cAOcdRZNY1ceQzj5eTLwIPDQ2nCcqp1xvcDDTLKah9PovrMJAg-XurzAw6W0HwEAAP__ue4ilg">