<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/65884>65884</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            【AArch64】neon big endian miscompiled 
        </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>
    https://godbolt.org/z/vWMz5K34r

```
#include <arm_neon.h>

extern void abort (void);

__attribute__((noinline)) uint8x16_t
wrap_vld1q_lane_u8 (const uint8_t *load, uint8x16_t vec) {
  return vld1q_lane_u8 (load, vec, 12);
}

int test_vld1q_lane_u8(const uint8_t *data) {
  uint8_t out[16];
  uint8_t overwrite = 7;
  int j;
  uint8x16_t in = vld1q_u8 (data);
  in = wrap_vld1q_lane_u8 (&overwrite, in);
  vst1q_u8 (out, in);
  for (j = 0; j < 13; j++)
    if (out[j] != (j == 12 ? overwrite : data[j])) {
      abort();
    }
  return 0;
}

int main (int argc, char **argv)
{
  uint64_t orig_data[2] = {0x1234567890abcdefULL, 0x13579bdf02468aceULL};
  test_vld1q_lane_u8((const uint8_t *)orig_data);
  return 0;
}
```

this code fail, when `-O3 -fno-inline`.

I see the https://llvm.org/docs/BigEndianNEON.html , but I still confuse about the asm:

```
        rev64   v0.16b, v0.16b
        ext     v0.16b, v0.16b, v0.16b, #8
        rev64   v0.16b, v0.16b
        ext     v0.16b, v0.16b, v0.16b, #8
```

this code seem do nothing, but appear many times. 

Can anyone give me some clue about this fail? Or just narrow this problem?

I opt bisect it, it's fail in `SLPVectorizerPass`, but I guess it just introduced this problem, but not the main point. 



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VV-Pq7YT_TTOy2gjYwOBhzwkm4109bu_e69UtX2MDEzAW7BT27B_Pn1lQ7KQbm_fihAYec7MOTPjQVgra4W4Jc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