Issue 88029
Summary RISCV `-mno-strict-align` generates problem instructions for some targets
Labels new issue
Assignees
Reporter sh1boot
    When passed ` --target=riscv64-linux-gnu -march=rv64gcv -mno-strict-align`, clang-18 and up generate `vle64` and `vse64` instructions for the following code despite receiving byte pointers:

```C
__attribute__((noinline))
void vector_memcpy(uint8_t* d, uint8_t const* p) {
  __builtin_memcpy(d, p, 16);
}
```
https://godbolt.org/z/x9ddoehTY

If the pointer is unaligned then my Kendryte K230 board (C908) will raise a bus error trying to execute this.

However, `-mno-strict-align` offers big performance gains for some scalar code, where unaligned access is supported just fine. There seems to be no way to specify that vector code should respect alignments while scalar code can do unaligned access.

Scalar code "seems to work" when you cast a byte pointer to a wider type when it's unaligned, but there are other issues with that and most portable code prefers `memcpy()` with the expectation that the compiler will optimise it correctly.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to