mailing list of musl libc
 help / color / mirror / code / Atom feed
* Minor arm __syscall_cp_asm optimisation
@ 2019-08-01  6:00 Patrick Oppenlander
  2019-08-06 13:07 ` Szabolcs Nagy
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Oppenlander @ 2019-08-01  6:00 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

Hi all,

while debugging something unrelated I noticed a minor optimisation we
can make to __syscall_cp_asm for arm.

Unless I'm missing something the only reason we needed to preserve the
link register was because we were using a branch-link instruction to
branch to __cp_cancel. Replacing this with a branch means we can avoid
the save/restore as the link register is no longer modified.

Patch attached.

Kind regards,

Patrick

[-- Attachment #2: 0001-don-t-unnecessarily-preserve-link-register.patch --]
[-- Type: text/x-patch, Size: 950 bytes --]

From dc8d33fdf483e65ecaa688be6fa2888f914db8cb Mon Sep 17 00:00:00 2001
From: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Date: Thu, 1 Aug 2019 14:34:59 +1000
Subject: [PATCH] don't unnecessarily preserve link register

---
 src/thread/arm/syscall_cp.s | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/thread/arm/syscall_cp.s b/src/thread/arm/syscall_cp.s
index a5730c08..e607dd42 100644
--- a/src/thread/arm/syscall_cp.s
+++ b/src/thread/arm/syscall_cp.s
@@ -11,19 +11,19 @@
 .type __syscall_cp_asm,%function
 __syscall_cp_asm:
 	mov ip,sp
-	stmfd sp!,{r4,r5,r6,r7,lr}
+	stmfd sp!,{r4,r5,r6,r7}
 __cp_begin:
 	ldr r0,[r0]
 	cmp r0,#0
-	blne __cp_cancel
+	bne __cp_cancel
 	mov r7,r1
 	mov r0,r2
 	mov r1,r3
 	ldmfd ip,{r2,r3,r4,r5,r6}
 	svc 0
 __cp_end:
-	ldmfd sp!,{r4,r5,r6,r7,lr}
+	ldmfd sp!,{r4,r5,r6,r7}
 	bx lr
 __cp_cancel:
-	ldmfd sp!,{r4,r5,r6,r7,lr}
+	ldmfd sp!,{r4,r5,r6,r7}
 	b __cancel
-- 
2.22.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Minor arm __syscall_cp_asm optimisation
  2019-08-01  6:00 Minor arm __syscall_cp_asm optimisation Patrick Oppenlander
@ 2019-08-06 13:07 ` Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2019-08-06 13:07 UTC (permalink / raw)
  To: musl

* Patrick Oppenlander <patrick.oppenlander@gmail.com> [2019-08-01 16:00:16 +1000]:
> Hi all,
> 
> while debugging something unrelated I noticed a minor optimisation we
> can make to __syscall_cp_asm for arm.
> 
> Unless I'm missing something the only reason we needed to preserve the
> link register was because we were using a branch-link instruction to
> branch to __cp_cancel. Replacing this with a branch means we can avoid
> the save/restore as the link register is no longer modified.

the change makes sense to me.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-06 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-01  6:00 Minor arm __syscall_cp_asm optimisation Patrick Oppenlander
2019-08-06 13:07 ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).