<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59224>59224</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] The add should be fold into load instruction compare to gcc
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
vfdff
</td>
</tr>
</table>
<pre>
* test, https://godbolt.org/z/MrhhsG9Eo
```
typedef void (*func_ptr) (void);
extern func_ptr __init_array_start [];
extern func_ptr __init_array_end [];
void __attribute__((no_stack_protector)) __exec_ctors(void)
{
func_ptr *fn;
for (fn = __init_array_start; fn < __init_array_end; ++fn) {
(*fn)();
}
}
```
* **llvm:** base on the kenel loop fragment, the ADD should be fold into LOAD, and use **ldr x0, [x19], #8** similar to gcc
```
.L3:
ldr x0, [x21, x19, lsl 3]
blr x0
cmp x19, x20
add x19, x19, 1
bne .L3
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVEtzmzAQ_jXioqkHhI3RgYMTml7S6aV3RiBh1MiSRxKp01_fXZk87PgQjWC1u9rdbx_QO_nSELajUYVI2D2dYjwGUu4Ie4C9d7J3Jq6c3wP3D56ffprCD_7dkbwl-Y5U-bITG1-OSqqRPjstKWE1eB5nO3TH6AnjKEENHEl5tzhIb3WKylv6epd2nbY6dsJ78dKFKHykZHNHNi3Y0S-YKCs_GSwkQes6EaPX_RxV1yWctXUYaHjqjt5FNUSHiBF016mTGjqUhA8JnNFvlzQorDcomLW9yjBdcKirR0tJ2d7IEbEm5f2nbFIa7A42eMZKfgyMaym2TaDrjxVO2m37Cri92bjlDYOA6GEb83xIY5CEvQiKOkvjpOiTsspQ49yRjl7sD8qmwUHVrm1pmNxsJO0VpAtU2-jo469di3cEtGUGT0sI6ekpRzm06lRw7BYyrKyXsEEftBGegov9MNwEvnosEeZFLdAxrnfnrMATxgBigqElBrsw6s2b0YV8OBzP8rPxiV3phZQX-jMprpxblSiivcwiU01RVXzDt5znmWxKyUsusqijUQ1A3-38MFVrgEt_Q4Ux2q0KGyfwFKKfh6ihU4M7HIVXS-my2Zvm6tPWcZr7FdwDJnX7TL7B_P-B-QdWhzArmPmHDWdsnU3Nlm03Y7Vmo8yLvKq2nBWyEGwc1nyzHhXPjOiVCYibMGbVX5pcwBnwZ7phOWNFweq8KMoiX1VcCbnl63FgtdzUJVnn6iC0WSEO_OdkvkmQ-nkfQGl0iOFdKULQe6tSmdC_mOPkfPM8ynHMUuAmAf8PNdlj2A">