public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Vladimir Makarov <vmakarov@redhat.com>
To: Tom de Vries <Tom_deVries@mentor.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH][IRA] Analysis of register usage of functions for usage by IRA.
Date: Wed, 13 Feb 2013 22:35:00 -0000	[thread overview]
Message-ID: <511C1538.308@redhat.com> (raw)
In-Reply-To: <5113FC6B.7090702@mentor.com>

On 13-02-07 2:11 PM, Tom de Vries wrote:
> Vladimir,
>
> On 25/01/13 16:36, Vladimir Makarov wrote:
>> On 01/25/2013 08:05 AM, Tom de Vries wrote:
>>> Vladimir,
>>>
>>> this patch adds analysis of register usage of functions for usage by IRA.
>>>
>>> The patch:
>>> - adds analysis in pass_final to track which hard registers are set or clobbered
>>>     by the function body, and stores that information in a struct cgraph_node.
>>> - adds a target hook fn_other_hard_reg_usage to list hard registers that are
>>>     set or clobbered by a call to a function, but are not listed as such in the
>>>     function body, such as f.i. registers clobbered by veneers inserted by the
>>>     linker.
>>> - adds a reg-note REG_CALL_DECL, to be able to easily link call_insns to their
>>>     corresponding declaration, even after the calls may have been split into an
>>>     insn (set register to function address) and a call_insn (call register), which
>>>     can happen for f.i. sh, and mips with -mabi-calls.
>>> - uses the register analysis in IRA.
>>> - adds an option -fuse-caller-save to control the optimization, on by default
>>>     at -Os and -O2 and higher.
> <SNIP>
>
>>> Bootstrapped and reg-tested on x86_64, Ada inclusive. Build and reg-tested on
>>> mips, arm, ppc and sh. No issues found. OK for stage1 trunk?
>>>
>>>
>> Thanks for the patch.  I'll look at it during the next week.
>>
> Did you get a chance to look at this?
Sorry for the delay with the answer.  I was and am quite busy with other 
more urgent things.  I'll work on it when I have more free time.  In any 
case, I'll do it before stage1 to have your patch ready.
>> Right now I see that the code is based on reload which uses
>> caller-saves.c.  LRA does not use caller-saves.c at all.  Right now we
>> have LRA support only for x86/x86-64 but the next version will probably
>> have a few more targets based on LRA.  Fortunately, LRA modification
>> will be pretty easy with all this machinery.
>>
> I see, thanks for noticing that. Btw I'm now working on a testsuite construct
> dg-size-compare to be able to do
>    dg-size-compare "text" "-fuse-caller-save" "<" "-fno-use-caller-save"
> which I could have used to create a generic testcase, which would have
> demonstrated that the optimization didn't work for x86_64.
I thought about implementing your optimization for LRA by myself. But it 
is ok if you decide to work on it.  At least, I am not going to start 
this work for a month.
> I'm also currently looking at how to use the analysis in LRA.
> AFAIU, in lra-constraints.c we do a backward scan over the insns, and keep track
> of how many calls we've seen (calls_num), and mark insns with that number. Then
> when looking at a live-range segment consisting of a def or use insn a and a
> following use insn b, we can compare the number of calls seen for each insn, and
> if they're not equal there is at least one call between the 2 insns, and if the
> corresponding hard register is clobbered by calls, we spill after insn a and
> restore before insn b.
>
> That is too coarse-grained to use with our analysis, since we need to know which
> calls occur in between insn a and insn b, and more precisely which registers
> those calls clobbered.

> I wonder though if we can do something similar: we keep an array
> call_clobbers_num[FIRST_PSEUDO_REG], initialized at 0 when we start scanning.
> When encountering a call, we increase the call_clobbers_num entries for the hard
> registers clobbered by the call.
> When encountering a use, we set the call_clobbers_num field of the use to
> call_clobbers_num[reg_renumber[original_regno]].
> And when looking at a live-range segment, we compare the clobbers_num field of
> insn a and insn b, and if it is not equal, the hard register was clobbered by at
> least one call between insn a and insn b.
> Would that work? WDYT?
>
As I understand you looked at live-range splitting code in 
lra-constraints.c.  To get necessary info you should look at ira-lives.c.
>> I am going to use ira-improv branch for some my future work for gcc4.9.
>> And I am going to regularly (about once per month) merge trunk into it.
>> So if you want you could use the branch for your work too.  But this is
>> absolutely up to you.  I don't mind if you put this patch directly to
>> the trunk at stage1 when the review is finished.
>>
> OK, I'd say stage1 then unless during review a reason pops up why it's better to
> use the ira-improv branch.
>
That is ok.  Stage1 then.

  reply	other threads:[~2013-02-13 22:35 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-25 13:05 Tom de Vries
2013-01-25 15:46 ` Vladimir Makarov
2013-02-07 19:12   ` Tom de Vries
2013-02-13 22:35     ` Vladimir Makarov [this message]
2013-03-14  9:35       ` Tom de Vries
2013-03-14 15:22         ` Vladimir Makarov
2013-03-29 12:54           ` Tom de Vries
2013-03-29 13:06             ` [PATCH][02/10] -fuse-caller-save - Add new reg-note REG_CALL_DECL Tom de Vries
2013-03-29 13:06             ` [PATCH][06/10] -fuse-caller-save - Collect register usage information Tom de Vries
2013-03-29 13:06             ` [PATCH][09/10] -fuse-caller-save - Add documentation Tom de Vries
2013-03-29 13:06             ` [PATCH][08/10] -fuse-caller-save - Enable by default at O2 and higher Tom de Vries
2013-03-29 13:06             ` [PATCH][10/10] -fuse-caller-save - Add test-case Tom de Vries
2013-03-29 13:06             ` [PATCH][03/10] -fuse-caller-save - Add implicit parameter to find_all_hard_reg_sets Tom de Vries
2013-03-29 13:06             ` [PATCH][07/10] -fuse-caller-save - Use collected register usage information Tom de Vries
2013-03-29 13:06             ` [PATCH][01/10] -fuse-caller-save - Add command line option Tom de Vries
2013-03-29 13:06             ` [PATCH][04/10] -fuse-caller-save - Add TARGET_FN_OTHER_HARD_REG_USAGE hook Tom de Vries
2013-03-29 13:06             ` [PATCH][05/10] -fuse-caller-save - Implement TARGET_FN_OTHER_HARD_REG_USAGE hook for ARM Tom de Vries
2013-03-30 16:10             ` [PATCH][IRA] Analysis of register usage of functions for usage by IRA Tom de Vries
2014-01-09 14:42               ` Richard Earnshaw
2014-01-09 20:56                 ` Tom de Vries
2014-01-09 21:10                   ` Andi Kleen
2014-01-10  0:22                     ` Tom de Vries
2014-01-10 11:39                   ` Richard Earnshaw
2014-01-10 16:44                     ` Tom de Vries
2014-01-13 16:16                     ` Tom de Vries
2014-01-14 10:00                       ` Richard Earnshaw
2013-03-30 17:11             ` [PATCH][02/10] -fuse-caller-save - Add new reg-note REG_CALL_DECL Tom de Vries
2013-03-30 17:11             ` [PATCH][05/10] -fuse-caller-save - Implement TARGET_FN_OTHER_HARD_REG_USAGE hook for ARM Tom de Vries
2013-12-06  0:54               ` Tom de Vries
2013-12-09 10:03                 ` Richard Earnshaw
2013-03-30 17:11             ` [PATCH][06/10] -fuse-caller-save - Collect register usage information Tom de Vries
2013-03-30 17:11             ` [PATCH][01/10] -fuse-caller-save - Add command line option Tom de Vries
2013-03-30 17:11             ` [PATCH][03/10] -fuse-caller-save - Add implicit parameter to find_all_hard_reg_sets Tom de Vries
2013-03-30 17:11             ` [PATCH][04/10] -fuse-caller-save - Add TARGET_FN_OTHER_HARD_REG_USAGE hook Tom de Vries
2013-12-07 15:07               ` [PATCH] -fuse-caller-save - Implement TARGET_FN_OTHER_HARD_REG_USAGE hook for MIPS Tom de Vries
2013-12-25 13:02                 ` Tom de Vries
2014-01-09 13:51                   ` [PING^2][PATCH] " Tom de Vries
2014-01-09 15:31                     ` Richard Sandiford
2014-01-09 23:43                       ` Tom de Vries
2014-01-10  8:47                         ` Richard Sandiford
2014-01-13 15:04                           ` Tom de Vries
2013-03-30 17:12             ` [PATCH][07/10] -fuse-caller-save - Use collected register usage information Tom de Vries
2013-12-06  0:56               ` Tom de Vries
2013-12-06  9:11                 ` Paolo Bonzini
2013-03-30 17:12             ` [PATCH][10/10] -fuse-caller-save - Add test-case Tom de Vries
2013-04-28 10:57               ` Richard Sandiford
2013-12-06  0:34                 ` Tom de Vries
2013-12-06  8:51                   ` Richard Sandiford
2013-03-30 17:12             ` [PATCH][08/10] -fuse-caller-save - Enable by default at O2 and higher Tom de Vries
2013-03-30 17:12             ` [PATCH][09/10] -fuse-caller-save - Add documentation Tom de Vries
2013-12-06  0:47         ` [PATCH][IRA] Analysis of register usage of functions for usage by IRA Tom de Vries
2014-01-14 19:36           ` Vladimir Makarov
2014-05-30  9:20             ` Tom de Vries
2014-09-01 16:41 ` Ulrich Weigand
2014-09-03 16:58   ` Tom de Vries
2014-09-03 18:12     ` Ulrich Weigand
2014-09-03 22:24       ` Tom de Vries
2014-09-04  7:37     ` Tom de Vries
2014-09-04 14:55       ` Vladimir Makarov

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=511C1538.308@redhat.com \
    --to=vmakarov@redhat.com \
    --cc=Tom_deVries@mentor.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).