<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64174>64174</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
x86-32: missed zext folding optimization for cvtsi2ss
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:codegen,
llvm:optimizations
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jroelofs
</td>
</tr>
</table>
<pre>
This function:
```
float foo(unsigned char x) {
return x;
}
```
compiles to (x86-32):
```
define float @foo(i8 zeroext %x) nounwind {
entry:
%tmp12 = uitofp i8 %x to float ; <float> [#uses=1]
ret float %tmp12
}
```
compiles to:
```
_foo:
subl $4, %esp
movzbl 8(%esp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, (%esp)
flds (%esp)
addl $4, %esp
ret
```
We should be able to use:
`cvtsi2ss 8($esp), %xmm0`
since we know the stack slot is already zext'd.
rdar://5907648
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU1FvszgQ_DXLy6qRsyaAH3hom8svOOkeTwYvwd9ncGSbNu2vPwEhzUlVpU-KHLEzmp0ZyzpGex6Zazi8wOGY6Sn1PtS_gmfnu5g13nzUf_c2YjeNbbJ-BPkM4ghiOwtx-y2fnfM6Yec9UDWNi7bBttcBr0AKoXxZeYiB0xRGvIK8jaA8fiu5nq0fLtZxxOQRqLpWxZMkIPWzHcOdHRlXV5CL1Zit8JOD52tCBDoszkY_je92NPjlkccUPh70FdAhDZc9IcgjTjb57oK2WiRmW8uWmSYUyBcE-bpO5F84t0tyihxBHvdwON41A6fN3k39D9v4uYB_58QPEeLUuCVJngO9zjs5Xu7o4N8-F7wCqm4YqY2or3di-5aipRjXUmZk5VyHQTyqbYxlvlAeZDde58xK-wbTxvzgN3D6oaR_GGPvJ2ewYdSN4_mSpsj3PhChEFsUXDPn_8u8-N5Uox1bxnfG36N_x9QzxqTb3xidT2gjahdYmw_85GsCKs3u0UwwOsyL6QR0OihRFnmVmVoaJZXOuN4XSuSVKgqV9XXTMMmyocKovJMdyUq1jam4PIi9MrTPbE2CpCipJEFlrnaqMI0UvO-0abUyHeSCB23dzrm3YefDObMxTlwX-b7MM6cbdnF580QzA-Rz6w2feQQioNevsb8kO9hPPT_9OIOHYxbqGXxqpnOEXDgbU_zak2xyXN_ep3zGwcbIZikFO--MHc_4KIqdD7hdQjYFV_cpXeK9q7NN_dTsWj8AnRZT69_TJfhf3Cag0xItAp2WdP8FAAD__7yiXKs">