[PATCH v4 3/3] riscv: Add and use alignment-ignorant memcpy
Richard Henderson
richard.henderson@linaro.org
Fri Jul 7 09:22:20 GMT 2023
On 7/6/23 20:29, Evan Green wrote:
> + /* Copy the last few individual bytes */
> + add a3, a1, a2
> +5:
> + lb a4, 0(a1)
> + addi a1, a1, 1
> + sb a4, 0(t6)
> + addi t6, t6, 1
> + bltu a1, a3, 5b
> +6:
> + ret
The only time you should be copying individual bytes is when the copy is smaller than
SZREG. Otherwise the tail can be handled like
add srcend, a1, a2
add dstend, a0, a2
REG_L tmp, -SZREG(srcend)
REG_S tmp, -SZREG(dstend)
There are other tricks that can be used to reduce the number of branches -- please examine
the x86 code. See e.g. the copy_0_15 block in sysdeps/x86_64/multiarch/memmove-ssse3.S.
r~
More information about the Libc-alpha
mailing list