Minor arm __syscall_cp_asm optimisation

Submitted by Patrick Oppenlander on Aug. 1, 2019, 6 a.m.

Details

Message ID CAEg67GkDW-3rOVHP=hSRyMYxVaMK_mTOJai8vyDkHRj5MYMmSQ@mail.gmail.com
State New
Series "Minor arm __syscall_cp_asm optimisation"
Headers show

Commit Message

Patrick Oppenlander Aug. 1, 2019, 6 a.m.
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

Patch hide | download patch | download mbox

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


Comments

Szabolcs Nagy Aug. 6, 2019, 1:07 p.m.
* 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.