[PATCH] Optimize epilogue in thumb __aeabi_{memmove,memset} implementations

Christos Gentsos christos.gentsos@cern.ch
Mon Sep 30 14:55:00 GMT 2019


The same pop instruction that is used to restore registers can be used
to return from the function (as it is already done in other function
implementations).
---
 newlib/libc/machine/arm/aeabi_memmove-thumb.S | 4 +---
 newlib/libc/machine/arm/aeabi_memset-thumb.S  | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/newlib/libc/machine/arm/aeabi_memmove-thumb.S b/newlib/libc/machine/arm/aeabi_memmove-thumb.S
index 61a72581..a0aad852 100644
--- a/newlib/libc/machine/arm/aeabi_memmove-thumb.S
+++ b/newlib/libc/machine/arm/aeabi_memmove-thumb.S
@@ -49,9 +49,7 @@ __aeabi_memmove:
 	subs	r3, r3, #1
 	bcs	1b
 2:
-	pop	{r4}
-	pop	{r1}
-	bx	r1
+	pop	{r4, pc}
 3:
 	movs	r3, #0
 	cmp	r2, #0
diff --git a/newlib/libc/machine/arm/aeabi_memset-thumb.S b/newlib/libc/machine/arm/aeabi_memset-thumb.S
index aa8f2719..5bb80b20 100644
--- a/newlib/libc/machine/arm/aeabi_memset-thumb.S
+++ b/newlib/libc/machine/arm/aeabi_memset-thumb.S
@@ -110,9 +110,7 @@ __aeabi_memset:
 	cmp	r4, r3
 	bne	8b
 9:
-	pop	{r4, r5, r6}
-	pop	{r1}
-	bx	r1
+	pop	{r4, r5, r6, pc}
 10:
 	movs	r3, r0
 	movs	r4, r1
-- 
2.23.0



More information about the Newlib mailing list