<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/137086>137086</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
AArch64: uses store from GP reg where vectorized reg would be better
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AArch64
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MatzeB
</td>
</tr>
</table>
<pre>
Repro:
```
#include <string.h>
#include <arm_neon.h>
#include <arm_sve.h>
void foobar(uint16_t *p, uint8_t *p2, uint64x2_t vec, int x) {
vec += (uint64x2_t){3, 4};
if (x) {
asm volatile(""); // side-effect so conditional move cannot be used.
vec |= (uint64x2_t){0x12, 0x34};
*p2 = vec[1];
*p = vec[0];
} else {
// Commenting out the next two instructions will improve code in the "then" branch!
vec ^= (uint64x2_t){0x34, 0x12};
*p = vec[0];
}
}
// clang++ -target aarch64-redhat-linux-gnu -O3 -S -o - test.cpp -march=armv9-a+sve2+fp16
```
The compiler ends up compiling the "then" part of the branch as:
```
...
umov w8, v0.h[0]
st1 { v0.b }[8], [x1]
strh w8, [x0]
```
while this could be done without going throgh the w8 GP register:
```
st1 { v0.b }[8], [x1]
str h0, [x0]
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVF2PqzYQ_TWTlxGRsSGQBx5gc7dPVau27ysDE3BrbGQbkt5fX5kke9NdrapKVqzMF-ecmbH0Xg2GqIK8gfy0k0sYrat-luE7NbvW9n9Xv9HsLIgaWA0Hdj-sBi6U6fTSE4J48cEpM-xHEN8--aSb3gxZ87XXr_TuZPVqVY9na1vpgJeLMiE9vAUEXs_AXzAayvt__jAcsit_C7hSFy3KBLwCPyIUDbAaox2BNyBOeC95SwB-hKIRMSeD4gTiFq7OMexfFRCln3C1WgalCXgJnG_nCKJB4K_AX9GrnhI6n6kL6C121vQqKGukxsmuhJ00xgZsCRdP_f5eeANXvHwBjl3TjSW7iieIG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