All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v3 1/2] riscv: simplify longjmp
Date: Tue, 23 Mar 2021 19:11:26 +0100	[thread overview]
Message-ID: <20210323181127.32411-2-xypron.glpk@gmx.de> (raw)
In-Reply-To: <20210323181127.32411-1-xypron.glpk@gmx.de>

The value returned by setjmp must be nonzero. If zero is passed as
parameter it must be replaced by 1.

This patch reduces the code size a bit.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
v3:
	no change
v2:
	correct typo in title
---
 arch/riscv/lib/setjmp.S | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/riscv/lib/setjmp.S b/arch/riscv/lib/setjmp.S
index 72bc9241f6..99d6195827 100644
--- a/arch/riscv/lib/setjmp.S
+++ b/arch/riscv/lib/setjmp.S
@@ -54,12 +54,8 @@ ENTRY(longjmp)
 	LOAD_IDX(sp, 13)

 	/* Move the return value in place, but return 1 if passed 0. */
-	beq a1, zero, longjmp_1
-	mv a0, a1
-	ret
-
-	longjmp_1:
-	li a0, 1
+	seqz a0, a1
+	add a0, a0, a1
 	ret
 ENDPROC(longjmp)
 .popsection
--
2.30.2

  reply	other threads:[~2021-03-23 18:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 18:11 [PATCH v3 0/2] riscv: simplify longjmp Heinrich Schuchardt
2021-03-23 18:11 ` Heinrich Schuchardt [this message]
2021-03-23 18:11 ` [PATCH v3 2/2] test: unit test for longjmp Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210323181127.32411-2-xypron.glpk@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.