]> git.ipfire.org Git - thirdparty/glibc.git/commit
riscv: Add RVV memcmp for both multiarch and non-multiarch builds
authorYao Zihong <zihong.plct@isrc.iscas.ac.cn>
Thu, 4 Jun 2026 23:28:06 +0000 (18:28 -0500)
committerPeter Bergner <bergner@tenstorrent.com>
Fri, 5 Jun 2026 00:02:07 +0000 (19:02 -0500)
commit2efc7026287273b4b3a1ce1a7b27791d3d860a5c
tree5831b6ef4468e338f60253fb827998594388bc68
parent93e6135904eec91f6aaf5500175e7593d260dbe7
riscv: Add RVV memcmp for both multiarch and non-multiarch builds

This patch adds an RVV-optimized implementation of memcmp for RISC-V and
enables it for both multiarch (IFUNC) and non-multiarch builds.

The implementation integrates Hau Hsu's 2023 RVV work under a unified
ifunc-based framework. A vectorized version (__memcmp_vector) is added
alongside the generic fallback (__memcmp_generic). The runtime resolver
selects the RVV variant when RISCV_HWPROBE_KEY_IMA_EXT_0 reports vector
support (RVV).

Currently, the resolver still selects the RVV variant even when the RVV
extension is disabled via prctl(). As a consequence, any process that
has RVV disabled via prctl() will receive SIGILL when calling memcmp().

Co-authored-by: Hau Hsu <hau.hsu@sifive.com>
Co-authored-by: Jerry Shih <jerry.shih@sifive.com>
Signed-off-by: Yao Zihong <zihong.plct@isrc.iscas.ac.cn>
Reviewed-by: Peter Bergner <bergner@tenstorrent.com>
sysdeps/riscv/multiarch/dl-symbol-redir-ifunc.h
sysdeps/riscv/multiarch/memcmp-generic.c [new file with mode: 0644]
sysdeps/riscv/multiarch/memcmp-vector.S [new file with mode: 0644]
sysdeps/riscv/rvv/memcmp.S [new file with mode: 0644]
sysdeps/unix/sysv/linux/riscv/multiarch/Makefile
sysdeps/unix/sysv/linux/riscv/multiarch/ifunc-impl-list.c
sysdeps/unix/sysv/linux/riscv/multiarch/memcmp.c [new file with mode: 0644]