<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/82936>82936</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
simd vectorization regression starting with clang 14
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nschaeff
</td>
</tr>
</table>
<pre>
A simple loop multiplying two arrays, with different multiplicity fails to vectorize efficiently on clang 14+, while it worked with clang 13.0.1
The loop is the following, where 4 consecutive values in data are multiplied by the same factor :
```C
for (int i=0; i<n; i++) {
for (int k=0; k<4; k++) data[4*i+k] *= factor[i];
}
```
See on godbolt to see the crazy code generated by clang 14+, while clang 13.0.1 correctly uses `vbroadcastsd` :
https://godbolt.org/z/desh4E49o
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsk12O6joMx1fjvliDUjel8NAHPi4buHcDaeK2uYQGJSmIWf1RKDODRkdC1Jbsv3-2YxWjHSbmFuo91MdCzWn0oZ2iHhX3fdF582h3GO3l6hid91e8zC7Zq3vYacB096hCUI8IdMC7TSMa2_cceEpfgVbb9MBeWRcxebyxTj7YT0bue6stT8k90E-onZoGLCXQ_ik2WsdoE959OLNZxF8x1UqsShBHELv_xheWjZhGxt475-92GhYNDowStZ8i6znZG-NNuZkj2gmNSgpV4G9QNtg9nipRXRh7lUkRqt1S6vW_FsvvsPiIiH0Oo42dElqojgKqfTYO02LkhvZAW4Rm_5P0nnX-yjpDdZCL8Z2VOaHeS6Bd1jpDfUSgHVTHFyLUewv1Eao3dWiOv3gX91_mPOzBm867lBcSmZ8966A-H6i9YRx44qDSMo-_7uV9Eah9CKzzGufIEWEtbl3wymgVUzSwFj8zHFO6xuzRCej0olj5MACdPoFOhuMo_5FbX5i2Mttqqwpuy0ZstqKkmoqxFY2qtCo3ddM1xtS6k2uq1UaWYitL05SFbUmQFEQ1kWwqWmmxWXcd9ZKYy2qtQAq-KOtWzt0uuXZhY5y53dC2WhdOdezi8x6Inm0CUT6N0Ob4j24eIkjhbEzxRyHZ5LiN9mK-H7hK1k8YeAgcYzZjUiHlq3l_yrKYg2t_jcWmce5W2l-ATrnE6_NxDf5_1gno9CSOQKcn9J8AAAD__5wxLRA">