[PATCH 06/12] RISC-V: memmove() size optimized version: Relax RAW dependency
m fally
marlene.fally@gmail.com
Wed Apr 9 06:46:55 GMT 2025
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 <christian.herber@oss.nxp.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
---
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
More information about the Newlib
mailing list