public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Segher Boessenkool <segher@kernel.crashing.org>, gcc-patches@gcc.gnu.org
Cc: bergner@linux.ibm.com
Subject: Re: [PATCH] combine: Do not combine moves from hard registers
Date: Mon, 22 Oct 2018 22:07:00 -0000	[thread overview]
Message-ID: <59f7ad07-5230-3b65-ed02-7f9e806c383e@redhat.com> (raw)
In-Reply-To: <68abf72a5400b96b9a100966331d3ad2056648e7.1540237620.git.segher@kernel.crashing.org>

On 10/22/18 2:17 PM, Segher Boessenkool wrote:
> On most targets every function starts with moves from the parameter
> passing (hard) registers into pseudos.  Similarly, after every call
> there is a move from the return register into a pseudo.  These moves
> usually combine with later instructions (leaving pretty much the same
> instruction, just with a hard reg instead of a pseudo).
> 
> This isn't a good idea.  Register allocation can get rid of unnecessary
> moves just fine, and moving the parameter passing registers into many
> later instructions tends to prevent good register allocation.  This
> patch disallows combining moves from a hard (non-fixed) register.
> 
> This also avoid the problem mentioned in PR87600 #c3 (combining hard
> registers into inline assembler is problematic).
> 
> Because the register move can often be combined with other instructions
> *itself*, for example for setting some condition code, this patch adds
> extra copies via new pseudos after every copy-from-hard-reg.
> 
> On some targets this reduces average code size.  On others it increases
> it a bit, 0.1% or 0.2% or so.  (I tested this on all *-linux targets).
> 
> I'll commit this to trunk now.  If there are problems, please don't
> hesitate to let me know!  Thanks.
> 
> 
> Segher
> 
> 
> 2018-10-22  Segher Boessenkool  <segher@kernel.crashing.org>
> 
> 	PR rtl-optimization/87600
> 	* combine.c: Add include of expr.h.
> 	(cant_combine_insn_p): Do not combine moves from any hard non-fixed
> 	register to a pseudo.
> 	(make_more_copies): New function, add a copy to a new pseudo after
> 	the moves from hard registers into pseudos.
> 	(rest_of_handle_combine): Declare rebuild_jump_labels_after_combine
> 	later.  Call make_more_copies.
I know we've gone back and forth on this stuff through the years,
particularly for targets with likely-to-spilled classes that are used
for register passing/return values.

I'm certainly willing to go with this as general guidance.  I wouldn't
be surprised if we find that things like CSE, fwprop and other passes
need twiddling over time to mimick what you're doing in combine.

jeff

  reply	other threads:[~2018-10-22 20:52 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22 21:06 Segher Boessenkool
2018-10-22 22:07 ` Jeff Law [this message]
2018-10-22 22:46   ` Segher Boessenkool
2018-10-23 10:54 ` Christophe Lyon
2018-10-23 12:36   ` Christophe Lyon
2018-10-23 13:10     ` Segher Boessenkool
2018-10-23 13:30       ` Christophe Lyon
2018-10-23 13:08   ` Segher Boessenkool
2018-10-23 13:50     ` Christophe Lyon
2018-10-24  1:50       ` Segher Boessenkool
2018-10-24  9:52         ` Christophe Lyon
2018-11-02 22:19           ` Renlin Li
2018-11-02 23:03             ` Segher Boessenkool
2018-11-02 23:54               ` Segher Boessenkool
2018-11-03  2:34                 ` Jeff Law
2018-11-05 12:35                   ` Renlin Li
2018-11-05 18:16                     ` Renlin Li
2018-11-07 23:02                       ` Segher Boessenkool
2018-11-09 10:21                         ` Richard Earnshaw (lists)
2018-11-05 22:50                     ` Segher Boessenkool
2018-10-24  9:38   ` Paul Hua
2018-10-23 16:16 ` Andreas Schwab
2018-10-23 16:28   ` Segher Boessenkool
2018-10-24 12:24     ` Andreas Schwab
2018-10-26 17:41       ` Steve Ellcey
2018-10-26 18:37         ` Segher Boessenkool
     [not found]           ` <7bc8697f-a09e-627f-b032-eba5ecb682ac@arm.com>
2018-11-08 20:34             ` Segher Boessenkool
2018-11-09 21:12               ` Jeff Law
2018-11-10  4:51                 ` Segher Boessenkool
2018-11-10 16:54                   ` Jeff Law
2018-11-12 11:57               ` Sam Tebbs
     [not found]               ` <e9104024-2f6a-6cb8-e366-39b96f7a72f2@arm.com>
2018-11-12 12:54                 ` Segher Boessenkool

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=59f7ad07-5230-3b65-ed02-7f9e806c383e@redhat.com \
    --to=law@redhat.com \
    --cc=bergner@linux.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.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).