Re: [PATCH 06/12] RISC-V: memmove() size optimized version: Relax RAW dependency

Kito Cheng <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CA+yXCZD2nFa2NbcwG-mpzkLGqV4jR9M6_S4Pk3iW_mHjdwKJjQ@mail.gmail.com>
LGTM

On Wed, Apr 9, 2025 at 2:57 PM m fally <[email protected]> wrote:
>
> Move the instruction that increments the remaining number of
> bytes to be copied inbetween the load and store instructions.
> This is done in order to relax the RAW dependency between the
> load and store instructions.
>
> Reviewed-by: Christian Herber <[email protected]>
> Signed-off-by: m fally <[email protected]>
> ---
>  newlib/libc/machine/riscv/memmove.S | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/newlib/libc/machine/riscv/memmove.S b/newlib/libc/machine/riscv/memmove.S
> index 671a6a158..6ecad9ad6 100644
> --- a/newlib/libc/machine/riscv/memmove.S
> +++ b/newlib/libc/machine/riscv/memmove.S
> @@ -28,9 +28,9 @@ memmove:
>    add   a4, a4, a3             /* in case of source address < destination address, increment both addresses by -1 before copying any data to obtain the correct start addresses */
>    add   a1, a1, a3
>  .Lcopy:
> -  lbu a5, 0(a1)                        /* copy bytes as long as a2 (= the number of bytes to be copied) > 0 */
> +  lbu a5, 0(a1)
> +  add   a2, a2, -1             /* copy bytes as long as a2 (= the number of bytes to be copied) > 0. the increment is done here to relax the RAW dependency between load and store */
>    sb a5, 0(a4)
> -  add   a2, a2, -1
>    bnez a2, .Lincrement
>
>  .Ldone:
> --
> 2.49.0
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.