<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64293>64293</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[vectorization] gcc generate better code for a loop body with scalar and array expansion
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zhongsir1
</td>
</tr>
</table>
<pre>
test: https://godbolt.org/z/eMedWs4Ef
```
void s257(void) {
for (int i = 1; i < LEN_2D; i++) {
for (int j = 0; j < LEN_2D; j++) {
aa[j][i] = a[i] + bb[j][i];
}
}
}
```
* gcc: generate a sve loop
```
.L3:
ld1d z31.d, p7/z, [x4, x0, lsl 3]
ld1d z30.d, p7/z, [x3, x0, lsl 3]
fadd z31.d, p7/m, z31.d, z30.d
st1d z31.d, p7, [x1, x0, lsl 3]
add x0, x0, x5
whilelo p7.d, w0, w2
b.any .L3
```
* llvm:
```
.LBB0_2: // Parent Loop BB0_1 Depth=1
// => This Inner Loop Header: Depth=2
add x13, x8, x12
ldr d1, [x13, #8]
ldr d2, [x13, #1032]
add x13, x9, x12
add x12, x12, #2048
fadd d1, d0, d1
cmp x12, #32, lsl #12 // =131072
fadd d2, d0, d2
str d1, [x13, #8]
str d2, [x13, #1032]
b.ne .LBB0_2
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE2P4jgQ_TWVS2mQXU4gHHIgk0a7Uu9qDyvtceTEhhiFOIpN092_fmUH0sAwGiky5VS9-ngVnnTO7HutC8hKyKpEnnxrx-Kztf3emZEntVUfhdfOg9hg6_3gQGyAtkDbvVW17fzCjnug7SfQVv-l1X8ufdkBq4BtYMkuT7y-WaPQUbYCyoMNtEZYlZMTcWdHBMpN79EgiAo5iDKa3_H15e8fVMU7UBmfO-wd-hDRLEQfHtCHZ2gpISsPkFWQlQayKsLlfKES6_o-AsRNZVhV18tsfhn3FFxO2uC-aQKje93rUXqNEt2bxs7a4Slw8SoC75c6neIKPwVfKKDvOKwm-r8jZOV7Gox3Fs7OdShCuxPsgmLPUOKXKNxJ9VjsGKz51ZRyinb-sbMpP_91_pB-8lzO7Oo5t6bTncVhNaU7R_-Zrv56IfsPDNQ85Zo22HVvx5m3nygtS_aDwham7xn_kaPuPb5aO2Dwcaz04FsQFZ83PEWCqEC84L-tcfhn3-txAv2hpdJjyHgF0t2UfKI5jyeneS8jKj4zFWOARH7DUQyhn0I4E_TI5KXG-r7GxUfXtxOeWJrfrXlqQ0We1Tx0cxxuQIKuWwwd0A0lXHC2ovuEdJNwdjn_24ljyG8nrhe9xusiny05UYVQa7GWiS74cs3yFXGeJm2R7_Jmt2yWjdrldSYaltZaaa4ana7YbiUTUxAjwXLG2TLlWbpYKlJ1s1vnS8aWO6EhZfooTbcIH1kQwcQ4d9LFMqW1SDpZ685FWSXq9RmjEyh0n4xFwHyrT3sHKeuM8-4rize-i3r8phtvR_MpvbF9kKJ903wJRq291yM2VukofjKKBwa9xrPxLbpGdnJE2SuU4yg_UL8PsnfG9slp7IoHLTe-PdWLxh6BtvFfM_18G0Z70I0H2sYBHNA2Dvh_AAAA__-zP6IT">