<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60804>60804</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Improve the assembly sequence for X == 6 ? 6 : 8 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) {
X == 6 ? 6 : 8
}
```
I get:
```
31 c0 xor %eax,%eax
83 ff 06 cmp $0x6,%edi
0f 95 c0 setne %al
8d 04 45 06 00 00 00 lea 0x6(,%rax,2),%eax
```
We could generate:
```
83 ff 06 cmp $0x6,%edi
b8 08 00 00 00 mov $0x8,%eax
0f 44 c7 cmove %edi,%eax
```
saving 5 bytes while reducing the length of the critical path.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU91upDwMfZpwY3UUHMiECy7ajkbqE3y9DcED-RrIbBJmp336FT_tSt3pdq3IxsDx8XESHaPtRqKalQ-sPGR6Sr0P9Yt-m5J-0b0NOums8e1r_eiHs3XExD3jB8bfveTbWtJpXOq1EMkxVB_pM8MK2P5h_QvgGZg4MHEACUwcF38Paiu5P9ysvfon6Cj9vQkAkYPhcNOuPsyBYUn6yvBxe9iASsDpBFzeAJrhvAILfpUbsLXvQH6CqrxNGimNNBNq90HTAi-gKGcmzre1miM9h4VDrTRhaRQZVp_6vTmg_wiMn1wLHY0UdPpmx77V_IXgRgFXn5tfbfCXj0mpP0bMT1AUYPZgBn-hdSda-y_Kor7YsYMSmtdEEX721hEEaiczv049gaOxSz3405KZYJM12sFZp36XtbVoK1HpjOpc7mUpKlSY9TWiKqo9KaRKir1qhUIuqkblTS50XlBma-QoOOaSV5gj7oqqNLnJtTRC5koZVnAatHU75y7DzocuszFOVEuueJE53ZCLyw1DbLR5obFl4v5ZSYa46MbBxkjtnT8nO9g3nawf52_lIQv1XPOumbrICu5sTPE3S7LJUf00nMM8yVmyjpGGxr1CpB8TjYbg5MMXtw38CFclsym4uk_pHOeDgkeGx86mfmp2xg8MjzPbFu7Owf9PJjE8LgIjw-Oi8VcAAAD__zlkIQ4">