<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64524>64524</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] CSE between SIMD register and general register
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
LatchBB
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/bv1h54Pj1
- src
```
#include <stdint.h>
#include <arm_neon.h>
uint64_t
test (uint64_t a, uint64x2_t b, uint64x2_t* rt)
{
uint64_t arr[2] = { 0x0123456789101112UL, 0x0123456789101113UL};
uint64_t res = a | arr[0];
uint64x2_t val = vld1q_u64 (arr);
*rt = vaddq_u64 (val, b);
return res;
}
```
gcc's asm:
```
test:
adrp x2, .LC0
ldr q31, [x2, #:lo12:.LC0]
add v0.2d, v0.2d, v31.2d
fmov x2, d31
str q0, [x1]
orr x0, x0, x2
ret
.LC0:
.xword 81985529206280466
.xword 81985529206280467
```
llvm's asm:
```
.LCPI0_0:
.xword 81985529206280466 // 0x123456789101112
.xword 81985529206280467 // 0x123456789101113
test: // @test
adrp x8, .LCPI0_0
mov x9, #4370 // =0x1112
movk x9, #35088, lsl #16
movk x9, #17767, lsl #32
ldr q1, [x8, :lo12:.LCPI0_0]
movk x9, #291, lsl #48
orr x0, x0, x9
add v0.2d, v0.2d, v1.2d
str q0, [x1]
ret
```
in which mov/movks are redundant and can be replaced by a `fmov`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVVuP2yoQ_jXjF7QWN98e_JBLI1XaI1Wq-hyB4cTuIfYWcDY9v74Cu8k6yXZLIjDMNx_fmBkjnOsOvdY1ZGvItokYfTvY-ln4pl2vEzmon3Xr_YsDtgK6A7o7DEoOxqeDPQDd_Q90J0-kzfiX7wTwFvBq6p-Qs828kOP5P00p6_rGjEojYBvnVdf7tAX26ZFZ2OO-10P_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