[EXT] [PATCH v5 05/18] riscv: Add RVV memcpy for multiarch and non-multiarch
Peter Bergner
bergner@tenstorrent.com
Wed Apr 22 21:21:23 GMT 2026
On 2/3/26 9:05 AM, Yao Zihong wrote:
> .../riscv/multiarch/dl-symbol-redir-ifunc.h | 1 +
> sysdeps/riscv/multiarch/memcpy-vector.S | 24 +++++++++
> sysdeps/riscv/rvv/memcpy.S | 54 +++++++++++++++++++
> .../unix/sysv/linux/riscv/multiarch/Makefile | 1 +
> .../linux/riscv/multiarch/ifunc-impl-list.c | 2 +
> .../unix/sysv/linux/riscv/multiarch/memcpy.c | 5 ++
> 6 files changed, 87 insertions(+)
> create mode 100644 sysdeps/riscv/multiarch/memcpy-vector.S
> create mode 100644 sysdeps/riscv/rvv/memcpy.S
LGTM, so pushed.
Reviewed-by: Peter Bergner <bergner@tenstorrent.com>
> static inline __typeof (__redirect_memcpy) *
> select_memcpy_ifunc (uint64_t dl_hwcap, __riscv_hwprobe_t hwprobe_func)
> {
> unsigned long long int v;
> + if (__riscv_hwprobe_one (hwprobe_func, RISCV_HWPROBE_KEY_IMA_EXT_0, &v) == 0
> + && (v & RISCV_HWPROBE_IMA_V) == RISCV_HWPROBE_IMA_V)
> + return __memcpy_vector;
> +
> if (__riscv_hwprobe_one (hwprobe_func, RISCV_HWPROBE_KEY_CPUPERF_0, &v) == 0
> && (v & RISCV_HWPROBE_MISALIGNED_MASK) == RISCV_HWPROBE_MISALIGNED_FAST)
> return __memcpy_noalignment;
These two hwprobe calls could potentially be combined into one call to hwprobe
with two keys, similar to what we do in riscv/multiarch/ifunc-impl-list.c,
but we'd have to manually code it since we don't have a __riscv_hwprobe_two
or some such interface. I also expect in the future, the majority of systems
will have vector, so maybe it'll be marginally faster to keep it this way?
..so I'm accepting the code as is and if someone prefers to combine them,
then they can submit a patch.
Thanks.
Peter
More information about the Libc-alpha
mailing list