Re: [PATCH] LoongArch: Improve memory ops

From: Rui Wang
Date: Mon Apr 10 2023 - 10:23:02 EST


On Mon, Apr 10, 2023 at 8:54 PM Xi Ruoyao <xry111@xxxxxxxxxxx> wrote:
> Regarding these functions: we have -ffreestanding which is preventing
> the compiler from optimizing for e.g. "memcpy(a, b, 8);" into a simple
> ld.d/st.d pair. A explicit compiler built-in usage like
>
> #define memcpy(a, b, c) __builtin_memcpy(a, b, c)
>
> would allow the compiler to do such kind of optimization. Will this
> improve the performance?

That's a good question. IIUC, the current compiler generates
inefficient code for constant-length memcpy, which may sacrifice
performance for compatibility, as not all hardware supports unaligned
memory access. We need a runtime CPU feature dispatch mechanism
similar to alternatives to improve the compiler. This is indeed a
problem that needs to be addressed.

Regards,
Rui