<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/81374>81374</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
aarch64: SLP of 4 byte add should not extend/then add using half-word and then truncate, just do the add
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pinskia
</td>
</tr>
</table>
<pre>
Take:
```
void f(unsigned char * __restrict a, unsigned char * __restrict b)
{
a[0] += b[0];
a[1] += b[1];
a[2] += b[2];
a[3] += b[3];
}
```
Right now aarch64 produces:
```
f:
ldr s0, [x1]
ldr s1, [x0]
uaddl v0.8h, v1.8b, v0.8b
xtn v0.8b, v0.8h
str s0, [x0]
ret
```
But it could just use add directly without an extra truncate at the end like:
```
f:
ldr s0, [x1]
ldr s1, [x0]
add v0.8b, v1.8b, v0.8b
str s0, [x0]
ret
```
Reductions, multiply, popcount, compares and many more have a similar issue of wanting to extend to half-word and then truncating at the end. Instead of treating the other 4 entries in the vector as not needed.
I found this while implmenting this similar thing in the GCC backend and I thought I would file this.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlFFv4ygQxz8Nfhk1wthpkgc_NI1yqnQPp717X2EzCWwxWDAkzbc_QdzbbnONtFUVxsyfYeYHjIzRHB1ix5ZbttxVMpH2oZuMi69GVr1Xl-4f-YqseWJ8x_gTe-Tzf_k8eaPgwMQ6uRJIwaBlACae4Pv3gJGCGQgkE89wV9EzsZk3WG2vBki23HK23AETW9bsoJ-_WfNRUX9S1DcK8UkhbhTNJ0XzUcFWu_8t_fr7zRw1gfNnkDIM-rGFKXiVBoxfITuw5gnmzec_q0IZI8-g2HL7Vqq40cT63c9v_EkqZQHgxBdrnWWnerHui8Gz8Yv4jVwZr65Zo3_VRPqc1O2mAekOm20iMASDT1bBjxQJUkSQSoEyAQeyFzgb0j4RSAf4RkECheQGSQiSgDQCOgXWfH0BD_85fhdm0dwBmvP8SOgOzruo7jP6hioNZLyLeemYLJnJXrI9-WnwyVG2Bz9OMmAE6RSM0l1g9AFByxOChGhGY2UAE2NC8Ac4S0fGHYF8ppoRkgct7eHh7IMqQUije4edpT9xL-DFRUKpciQKePVnpyeNAVpAR8FgBOPK9AkH8gFkBOcJHKJCtbhW9wIHn8puJsJZG4tgxsmOOOeXp9-zJ52n5ph_PD9DL4fXnHtO9wXyPclP7QXO5T4dcrAcYFGprlGbZiMr7OoVXy03TctXle7a9bJtEevHdtk37WFYr3j7uBZcDKJWvMbKdIKLloua15uG89Vi3TSPkiPyvh7WvdqwluMojV1YexoXPhyrwrhb182qrazs0cbSOoVweL4eABO5wVShy2se-nSMrOXWRIo_o5Ahi93cMXI_-PvPvzLuFvoLXZ9I1KXMjPR6hkzsy6FlZ4qZ1dcnivnSlBenfOGZF1Up2E4TTaU1iT0T-6MhnfrF4Ecm9jm7eXiYgv-BAzGxLzVFJval5n8DAAD__3Bax8w">