public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Renlin Li <renlin.li@foss.arm.com>
Cc: Jeff Law <law@redhat.com>,
	Christophe Lyon <christophe.lyon@linaro.org>,
	       gcc Patches <gcc-patches@gcc.gnu.org>,
	bergner@linux.ibm.com
Subject: Re: [PATCH] combine: Do not combine moves from hard registers
Date: Mon, 05 Nov 2018 22:50:00 -0000	[thread overview]
Message-ID: <20181105225004.GA5994@gate.crashing.org> (raw)
In-Reply-To: <c9cf3c78-0c1b-e1ea-07a3-fa18055d1cfb@foss.arm.com>

Hi!

On Mon, Nov 05, 2018 at 12:35:24PM +0000, Renlin Li wrote:
> >>--- a/gcc/combine.c
> >>+++ b/gcc/combine.c
> >>@@ -14998,6 +14998,8 @@ make_more_copies (void)
> >>  	    continue;
> >>  	  if (TEST_HARD_REG_BIT (fixed_reg_set, REGNO (src)))
> >>  	    continue;
> >>+	  if (REG_P (dest) && TEST_HARD_REG_BIT (fixed_reg_set, REGNO 
> >>(dest)))
> >>+	    continue;
> >>  
> >>  	  rtx new_reg = gen_reg_rtx (GET_MODE (dest));
> >>  	  rtx_insn *new_insn = gen_move_insn (new_reg, src);
> >>-- 1.8.3.1
> >It certainly helps the armeb test results.
> 
> Yes, I can also see it helps a lot with the regression test.
> Thanks for working on it!

I committed a variant that does this only for frame_pointer_rtx, as r265821.

> Beside the correctness issue, there are performance regression issues as 
> other people also reported.
> 
> I analysised a case, which is gcc.c-torture/execute/builtins/memcpy-chk.c
> In this case, two additional register moves and callee saves are emitted.
> 
> The problem is that, make_more_moves split a move into two. Ideally, the RA 
> could figure out and
> make the best register allocation. However, in reality, scheduler in some 
> cases will reschedule
> the instructions, and which changes the live-range of registers. And thus 
> change the interference graph
> of pseudo registers.
> 
> This will force the RA to choose a different register for it, and make the 
> move instruction not redundant,
> at least, not possible for RA to eliminate it.
> 
> For example,
> 
> set r102, r1
> 
> After combine:
> insn x: set r103, r1
> insn x+1: set r22, r103
> 
> After scheduler:
> insn x: set r103, r1
> ...
> ...
> ...
> insn x+1: set r102, r103
> 
> After IRA, r1 could be assigned to operands used in instructions in between 
> insn x and x+1.
> so r23 is conflicting with r1. LRA has to assign r23 a different hard 
> register.
> This cause one additional move, and probably one more callee save/restore.
> 
> Nothing is obviously wrong here. But...
> 
> One simple case probably not beneficial is to split hard register store.

You mean a store from a hard reg directly to memory?  Leaving that
constrains scheduling.

> According to your comment on make_more_moves, you might want to apply the 
> transformation only
> on hard-reg-to-pseudo-copy?

hard-reg-to-anything really.  Actually making it do this only for pseudos
caused a lot of degradation for some targets iirc.  I can do more tests.

Almost all reported degradations are cases where RA does not make the
best decision.  There are other cases where this combine change makes
better code than before.  (If this was not true, a greedy RA would work
well.)


Segher

  parent reply	other threads:[~2018-11-05 22:50 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
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 [this message]
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=20181105225004.GA5994@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=bergner@linux.ibm.com \
    --cc=christophe.lyon@linaro.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=renlin.li@foss.arm.com \
    /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).