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 v7] xtensa: Eliminate the use of callee-saved register that saves and restores only once
Date: Thu, 23 Feb 2023 14:34:22 -0800 [thread overview]
Message-ID: <CAMo8BfJ13600rJtbYY98=+En1S_Ea2RMCg4jdb7OypzEd6Whww@mail.gmail.com> (raw)
In-Reply-To: <20fe3e31-0660-386c-7e6d-bc0b6c0f64ad@yahoo.co.jp>
On Thu, Feb 16, 2023 at 11:54 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 (with two exceptions; i. the register saved to/restored
> from is the stack pointer, ii. the function needs an additional stack
> pointer adjustment to grow the stack).
>
> e.g. in the following example, if there are no other occurrences of
> register A14:
>
> ;; before
> ; prologue {
> ...
> s32i.n a14, sp, 16
> ... ;; no frame pointer needed
> ;; no additional stack growth
> ; } prologue
> ...
> mov.n a14, a6 ;; A6 is not SP
> ...
> call0 foo
> ...
> mov.n a8, a14 ;; A8 is not SP
> ...
> ; epilogue {
> ...
> l32i.n a14, sp, 16
> ...
> ; } epilogue
>
> It can be possible like this:
>
> ;; after
> ; prologue {
> ...
> (no save needed)
> ...
> ; } prologue
> ...
> s32i.n a6, sp, 16 ;; replaced with A14's slot
> ...
> call0 foo
> ...
> l32i.n a8, sp, 16 ;; through SP
> ...
> ; epilogue {
> ...
> (no restoration needed)
> ...
> ; } epilogue
>
> This patch adds the abovementioned logic to the function prologue/epilogue
> RTL expander code.
>
> gcc/ChangeLog:
>
> * config/xtensa/xtensa.cc (machine_function): Add new member
> 'eliminated_callee_saved_regs'.
> (xtensa_can_eliminate_callee_saved_reg_p): New function to
> determine whether the register can be eliminated or not.
> (xtensa_expand_prologue): Add invoking the above function and
> elimination the use of callee-saved register by using its stack
> slot through the stack pointer (or the frame pointer if needed)
> directly.
> (xtensa_expand_prologue): Modify to not emit register restoration
> insn from its stack slot if the register is already eliminated.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/xtensa/elim_callee_saved.c: New.
> ---
> gcc/config/xtensa/xtensa.cc | 134 ++++++++++++++----
> .../gcc.target/xtensa/elim_callee_saved.c | 37 +++++
> 2 files changed, 146 insertions(+), 25 deletions(-)
> create mode 100644 gcc/testsuite/gcc.target/xtensa/elim_callee_saved.c
Regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master.
--
Thanks.
-- Max
prev parent reply other threads:[~2023-02-23 22:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20fe3e31-0660-386c-7e6d-bc0b6c0f64ad.ref@yahoo.co.jp>
2023-02-17 7:54 ` Takayuki 'January June' Suwa
2023-02-23 22:34 ` 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='CAMo8BfJ13600rJtbYY98=+En1S_Ea2RMCg4jdb7OypzEd6Whww@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).