<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/145121>145121</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Small arrays of MaybeUninit::<u8>::uninit() are deoptimized to all zeroes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
saethlin
</td>
</tr>
</table>
<pre>
I started by looking at https://github.com/rust-lang/rust/issues/139355 but it looks like the root cause can be produce with much less Rust code: https://godbolt.org/z/4Kv5Gbdse
As far as I can tell, things go wrong twice. SROA tries to splat the undef i8, but it generates a generic sequence of instructions in the process instead of just an undef of the target type. Then EarlyCSE sees the splat and replaces it with a 0.
I have a candidate fix for this, though I'm a bit of a novice at working on LLVM.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8U8GO4zYM_Rr5QkzgSHEmOfiQTifFoLsosNP2TkuMrR1FckUqaebrCzkBivawgAFLoPj4HvmIzH6MRL3qflLdzw0WmVLuGUmm4GMzJHfr34AFs5CD4QYhpQ8fR0CBSWRmZQ5KH5U-jl6mMqxsOit9zIXlKWAcH2elj565ECt9XJu96ToYioCXBY8h-A8CmQhySgIWCxNYjDAQzDm5YgmuXiY4FztBIGb4VljAJkfKHP7PJLkhBVmlXMt_Kn3c_Hrpfhkck2oPqj0cGE6YARnelipCISj9AjL5ODKMCa45xRHk6i2t4P3bbweQ7IlBEvAcUBauJTo6gd_V1IeakSJlFGLA-9lbYPqrULQE6QQ-suRixafI4OMCM-dkq6IaI3T12fcqDuOjQjot7wTzSAJym2kFv08U4RVzuL28vwJT5TbRgxxGB5nmgJa4slpah9Cu7vLfYMILAVbtzjsUgpP_G04p1w7wvROpjBO8Kf18BoTBS2WBENPFW6rDv6a8-CBF-PLlz6-rxvXG7c0eG-rXz1272Zqt2TRT_4x77dqdac3Juu261ZtB027fra11-_Wza3yvW921W91q05lus6K96bYnY0jbrRmwVZuWzujDKoTLuU61WbzUrzfdWq-bgAMFXhysdaQrLFGldTV07mvS01BGVps2eBb-F0a8BOrfzxgCYM5446ryK94G-iP66KVaqn4vZafM6_1W7hG9U3oPmAkcpVn82X-Sq_6oYJ-UE3FTcuh_sCSVx-P3NOf0nex_9-Qu79LrfwIAAP__lxo2Iw">