From: Max Filippov <jcmvbkbc@gmail.com>
To: "Takayuki 'January June' Suwa" <jjsuwa_sys3175@yahoo.co.jp>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] xtensa: Eliminate the use of callee-saved register that saves and restores only once
Date: Mon, 16 Jan 2023 00:27:48 -0800 [thread overview]
Message-ID: <CAMo8BfJuS=nFLfJNNYVTAEL6mfPvXdn45b0z07wTDyn8kKmDeA@mail.gmail.com> (raw)
In-Reply-To: <d3e65485-20e4-9513-3bc5-a6f964fc99b7@yahoo.co.jp>
Hi Suwa-san,
On Sun, Jan 15, 2023 at 6:53 PM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> In the case of the CALL0 ABI, values that must be retained before and
> after function calls are placed in the callee-saved registers (A12
> through A15) and referenced later. However, it is often the case that
> the save and the reference are each only once and a simple register-
> register move.
>
> e.g. in the following example, if there are no other occurrences of
> register A14:
>
> ;; before
> ; prologue {
> ...
> s32i.n a14, sp, 16
> ...
> ; } prologue
> ...
> mov.n a14, a6
> ...
> call0 foo
> ...
> mov.n a8, a14
> ...
> ; epilogue {
> ...
> l32i.n a14, sp, 16
> ...
> ; } epilogue
>
> It can be possible like this:
>
> ;; after
> ; prologue {
> ...
> (deleted)
> ...
> ; } prologue
> ...
> s32i.n a6, sp, 16
> ...
> call0 foo
> ...
> l32i.n a8, sp, 16
> ...
> ; epilogue {
> ...
> (deleted)
> ...
> ; } epilogue
>
> This patch introduces a new peephole2 pattern that implements the above.
>
> gcc/ChangeLog:
>
> * config/xtensa/xtensa.md: New peephole2 pattern that eliminates
> the use of callee-saved register that saves and restores only once
> for other register, by using its stack slot directly.
> ---
> gcc/config/xtensa/xtensa.md | 58 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 58 insertions(+)
This change introduces a bunch of test failures in cases where alloca
or similar mechanisms are used in a function and a15 is used as a
stack frame pointer. E.g., gcc.c-torture/execute/pr82210.c has the
following diff:
@@ -20,9 +20,8 @@
srli a10, a10, 4
slli a10, a10, 4
s32i.n a12, sp, 8
- s32i.n a15, sp, 0
s32i.n a0, sp, 12
- mov.n a15, sp
+ s32i.n sp, sp, 0
sub sp, sp, a10
mov.n a6, sp
mov.n a12, a6
@@ -59,11 +58,10 @@
addi.n a2, a2, 4
bne a12, a13, .L6
.L1:
- mov.n sp, a15
+ l32i.n sp, sp, 0
l32i.n a0, sp, 12
l32i.n a12, sp, 8
l32i.n a13, sp, 4
- l32i.n a15, sp, 0
addi sp, sp, 16
ret.n
.size foo, .-foo
--
Thanks.
-- Max
prev parent reply other threads:[~2023-01-16 8:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <d3e65485-20e4-9513-3bc5-a6f964fc99b7.ref@yahoo.co.jp>
2023-01-16 2:52 ` Takayuki 'January June' Suwa
2023-01-16 8:27 ` Max Filippov [this message]
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='CAMo8BfJuS=nFLfJNNYVTAEL6mfPvXdn45b0z07wTDyn8kKmDeA@mail.gmail.com' \
--to=jcmvbkbc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jjsuwa_sys3175@yahoo.co.jp \
/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 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 read-only IMAP folder(s) and NNTP newsgroup(s).