[03/12] RISC-V: memmove() size optimized version: Rename local labels

Message ID 20250409064701.3435-4-marlene.fally@gmail.com
State New
Headers
Series newlib: RISC-V: Optimize memory and string functions for code size |

Commit Message

m fally April 9, 2025, 6:46 a.m. UTC
  Rename local lables so that the structure of the function is clearer.

Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
---
 newlib/libc/machine/riscv/memmove.S | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Comments

Kito Cheng April 9, 2025, 7:39 a.m. UTC | #1
LGTM

On Wed, Apr 9, 2025 at 2:48 PM m fally <marlene.fally@gmail.com> wrote:
>
> Rename local lables so that the structure of the function is clearer.
>
> Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
> Signed-off-by: m fally <marlene.fally@gmail.com>
> ---
>  newlib/libc/machine/riscv/memmove.S | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/newlib/libc/machine/riscv/memmove.S b/newlib/libc/machine/riscv/memmove.S
> index 123ab3834..a77ac44be 100644
> --- a/newlib/libc/machine/riscv/memmove.S
> +++ b/newlib/libc/machine/riscv/memmove.S
> @@ -14,26 +14,26 @@
>  .global memmove
>  .type  memmove, @function
>  memmove:
> -  beqz a2, 2f
> +  beqz a2, .Ldone
>
>    mv a4, a0
>    li a3, 1
> -  bgtu  a1, a0, 1f
> +  bgtu  a1, a0, .Lcopy
>
>    li a3, -1
>    add   a4, a4, a2
>    add   a1, a1, a2
>
> -3:
> +.Lincrement:
>    add   a4, a4, a3
>    add   a1, a1, a3
> -1:
> +.Lcopy:
>    lb a5, 0(a1)
>    sb a5, 0(a4)
>    add   a2, a2, -1
> -  bnez a2, 3b
> +  bnez a2, .Lincrement
>
> -2:
> +.Ldone:
>    ret
>
>    .size        memmove, .-memmove
> --
> 2.49.0
>
  

Patch

diff --git a/newlib/libc/machine/riscv/memmove.S b/newlib/libc/machine/riscv/memmove.S
index 123ab3834..a77ac44be 100644
--- a/newlib/libc/machine/riscv/memmove.S
+++ b/newlib/libc/machine/riscv/memmove.S
@@ -14,26 +14,26 @@ 
 .global memmove
 .type	memmove, @function
 memmove:
-  beqz a2, 2f
+  beqz a2, .Ldone
 
   mv a4, a0
   li a3, 1
-  bgtu  a1, a0, 1f
+  bgtu  a1, a0, .Lcopy
 
   li a3, -1
   add   a4, a4, a2
   add   a1, a1, a2
 
-3:
+.Lincrement:
   add   a4, a4, a3
   add   a1, a1, a3
-1:
+.Lcopy:
   lb a5, 0(a1)
   sb a5, 0(a4)
   add   a2, a2, -1
-  bnez a2, 3b
+  bnez a2, .Lincrement
 
-2:
+.Ldone:
   ret
 
   .size	memmove, .-memmove