[PATCH 07/12] RISC-V: memcpy() size optimized version: Replace lb with lbu

Kito Cheng kito.cheng@gmail.com
Wed Apr 9 07:19:47 GMT 2025


Although I think it's no difference, but maybe some arch may have
higher cost to doing the sign-extension, so LGTM

On Wed, Apr 9, 2025 at 2:59 PM m fally <marlene.fally@gmail.com> wrote:
>
> From: Mahmoud Abumandour <ma.mandourr@gmail.com>
>
> Replace lb with lbu to avoid unnecessary sign extension.
>
> Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
> Signed-off-by: Mahmoud Abumandour <ma.mandourr@gmail.com>
> ---
>  newlib/libc/machine/riscv/memcpy-asm.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/newlib/libc/machine/riscv/memcpy-asm.S b/newlib/libc/machine/riscv/memcpy-asm.S
> index 5571e4704..d05ff5055 100644
> --- a/newlib/libc/machine/riscv/memcpy-asm.S
> +++ b/newlib/libc/machine/riscv/memcpy-asm.S
> @@ -18,7 +18,7 @@ memcpy:
>    beqz a2, 2f
>
>  1:
> -  lb t2, 0(a1)
> +  lbu t2, 0(a1)
>    sb t2, 0(t1)
>    add   a2, a2, -1
>    add   t1, t1, 1
> --
> 2.49.0
>


More information about the Newlib mailing list