public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jim Wilson <jimw@sifive.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 2/2] gcc/riscv: Add a mechanism to remove some calls to _riscv_save_0
Date: Sat, 24 Aug 2019 17:18:00 -0000	[thread overview]
Message-ID: <CAFyWVaZ8rLoA1yg3SqiJc4_XwCqCRkTjXAW9QC7K7oOkM0b2Ww@mail.gmail.com> (raw)
In-Reply-To: <bbb9338f2c4bdc2f573de3b7f54f81b56bce4d13.1566241797.git.andrew.burgess@embecosm.com>

On Mon, Aug 19, 2019 at 12:15 PM Andrew Burgess
<andrew.burgess@embecosm.com> wrote:
> The solution presented in this patch offers a partial solution to this
> problem.  By using the TARGET_MACHINE_DEPENDENT_REORG pass to
> implement a very limited pattern matching we identify functions that
> call _riscv_save_0 and _riscv_restore_0, and which could be converted
> to make use of a tail call.  These functions are then converted to the
> non save/restore tail call form.

Looking at this patch, I noticed a typo "sone" -> "some".  You are
using the British spellings of optimise, optimising, and optimisation.

You have t0/x5 in SIBCALL_REG_P which I'd prefer to avoid because it
is the alternative return reg.  SIBCALL_REG_P looks like a potential
maintenance problem, as it is duplicating info already available in
REG_CLASS_CONTENTS and riscv_regno_to_class.  Maybe you can just use
riscv_regno_to_class to compute the info, that avoids adding another
copy of the info.

Similarly callee_saved_reg_p is duplicating info available elsewhere.
You can probably just check call_used_regs and check for a 0 value.

You have two loops to look for NOTE_INSN_PROLOGUE_END, but these will
be small functions so not necessarily a problem.

I'm wondering how well this works with debug info, since deleting the
save_0, restore_0, and call will be deleting REG_NOTES that have call
frame info, and you aren't adding anything back.  But it looks like
this works out OK as you aren't trying to change the frame, so the
info looks like it should still be right with those REG_NOTES deleted.
I didn't see anything obviously wrong here.

Otherwise, the basic logic looks fine.  It isn't obvious why it is
failing.  You will have to debug some of the failing testcases and
refine the patch to work for them.

I do see about a 1.5% size decrease for libc.a and a 2.5% size
decrease for libstdc++.a for a 32-bit newlib toolchain build with
-msave-restore hardwired on, with versus without your patch.  So it is
reducing code size.

Jim

  parent reply	other threads:[~2019-08-24  0:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-19 19:31 [PATCH 0/2] RISCV: Reduce code size when compiling with -msave-restore Andrew Burgess
2019-08-19 19:47 ` [PATCH 2/2] gcc/riscv: Add a mechanism to remove some calls to _riscv_save_0 Andrew Burgess
2019-08-23  7:46   ` Jim Wilson
2019-08-26  2:17     ` Jim Wilson
2019-08-31  2:55       ` Jim Wilson
2019-08-31 13:12         ` Andreas Schwab
2019-08-31 13:57         ` Andreas Schwab
2019-09-06 23:41           ` Jim Wilson
2019-08-24 17:18   ` Jim Wilson [this message]
2019-10-21 12:53   ` Andrew Burgess
2019-10-23  0:59     ` Jim Wilson
2019-10-28 17:18       ` Andrew Burgess
2019-08-19 19:50 ` [PATCH 1/2] gcc/riscv: Include more registers in SIBCALL_REGS Andrew Burgess
2019-08-19 19:54   ` Andrew Waterman
2019-08-23  7:13   ` Jim Wilson
2019-08-24 10:55     ` Jim Wilson
2019-10-16 21:14   ` [PATCH] RISC-V: " Jim Wilson
2019-10-17 14:15     ` Andrew Burgess
2019-10-17 22:05       ` Jim Wilson
2019-10-17 22:22         ` Andrew Burgess

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=CAFyWVaZ8rLoA1yg3SqiJc4_XwCqCRkTjXAW9QC7K7oOkM0b2Ww@mail.gmail.com \
    --to=jimw@sifive.com \
    --cc=andrew.burgess@embecosm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).