<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64696>64696</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
arm neon ldrb before st2 error lead to compare fail
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hstk30
</td>
</tr>
</table>
<pre>
clang: https://godbolt.org/z/xW5s7s35q
gcc: https://godbolt.org/z/P5Wv7Y4zh
## code
```
#include <arm_neon.h>
extern void abort (void);
int test_vst2_lane_u8 (const uint8_t *data) {
uint8x8x2_t vectors;
for (int i = 0; i < 2; i++, data += 8) {
vectors.val[i] = vld1_u8 (data);
}
uint8_t temp[2];
vst2_lane_u8 (temp, vectors, 6);
// printf("temp[0]: %d\n", temp[0]);
// printf("temp[1]: %d\n", temp[1]);
//printf("vectors.val[0][6]: %d\n", vget_lane_u8(vectors.val[0], 6));
//printf("vectors.val[1][6]: %d\n", vget_lane_u8(vectors.val[1], 6));
for (int i = 0; i < 2; i++) {
if (temp[i] != vget_lane_u8 (vectors.val[i], 6)) /* error */
return 1;
}
return 0;
}
int main (int argc, char **argv)
{
uint64_t orig_data[8] = {
0x1234567890abcdefULL, 0x13579bdf02468aceULL,
};
if (test_vst2_lane_u8 ((const uint8_t *)orig_data))
abort ();;
return 0;
}
```
I see the asm
```
test_vst2_lane_u8: // @test_vst2_lane_u8
sub sp, sp, #16
ldp d0, d1, [x0]
add x8, sp, #12
ldrb w11, [sp, #13] // temp[1]
st2 { v0.b, v1.b }[6], [x8] // vst2_lane_u8 (temp, vectors, 6);
umov w8, v0.b[6]
ldrb w9, [sp, #12] // temp[0]
umov w10, v1.b[6]
cmp w9, w8, uxtb
ccmp w11, w10, #0, eq
cset w0, ne
add sp, sp, #16
ret
```
The error is caused because the `temp[1]` is loaded before `st2`, so the compare fail.
I switch it like :
```
st2 { v0.b, v1.b }[6], [x8] // vst2_lane_u8 (temp, vectors, 6);
umov w8, v0.b[6]
ldrb w11, [sp, #13] // temp[1]
ldrb w9, [sp, #12] // temp[0]
```
and recompile it, it's OK.
Anyone have idea to fix it?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVluPozYU_jXOy9FGxg63Bx5yaaSqK7UPrVZ9igx2gruAs7ZhsvvrKxvIAMmMOu1Lowgz4-PvO5fvnJgZIy-NEBkKdyg8rFhrS6Wz0tivFK9yxb9nRcWaC6JbKK29GkS3iBwROV4Uz1Vl10pfEDn-QOR4-xKa2NDwG8IHhLf981IU_-Tsb-GXLv5z86Ocnh2ehCJCoVBcwOz_ER6-o5lsiqp1VnTPdH1qhGrWJaI_TU-JmxW6gU5JDixX2gIiifsLkRTR3dRUNhasMPbUGUtOFWvEqU2ceaEaY6GVjU1O7vyWM8sQSQHFAwD0u7fkRk4WOlFYpc0dHuCstANyDBIQPQBGdOdf90D8KyI7_92DAwf3Tg-QLFhgxF53rELhTqLw4PG6igeDt4NzE3YUH6Zx3iOxor6icEdQeJhYL6P3VmR_j4rsIXpMXl9ouGrZ2DMiCSJkgMcefguIhByF-wYR4jCmu1O0N3GCd3GCpzhTmHnmPG-4i56Ddhdhxxw4vTweHbPwAcrg31MGb1F-WF9TOcnzvb6jlEjg1TTxBR6ckXNnAMBHvgWhtffDZ6Kn0MK2uoHgmRph3MWv8cyV6uKpmWzG2Ji-FI65KNnAs2X60jk_huOLvDilR5uTBaXl5eQ7I9wlY9PMGgvfAkI3YRQnKWZ5wcX5j8-fHRm-BTSM05yfMdlECStEvzGNZ1mPMbNPhsmzeYJI-upgX-G7X_ehNdR9SfVODhcD0z9_BiME2FIAM_V78_XBeafZp5-hZdEGP565h-E-ps371c-T_okIDaK5WcWvfuXYj8PAm4W7m--7mSXj3K-3ZA5IloDaE78EI9arKe1l7yOYjpK545b0kcY76PA69_0arHNf-6GjBye9uKZp-eg4HTnbWnXeaR-bZ-2Z4I3g0ofYyN2Xx2p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