public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <Tom_deVries@mentor.com>
To: Richard Henderson <rth@redhat.com>
Cc: Eric Botcazou <ebotcazou@adacore.com>, <gcc-patches@gcc.gnu.org>,
	Jan Hubicka <hubicka@ucw.cz>, <rdsandiford@googlemail.com>
Subject: Re: -fuse-caller-save - Collect register usage information
Date: Thu, 19 Jun 2014 16:06:00 -0000	[thread overview]
Message-ID: <53A30A69.7060905@mentor.com> (raw)
In-Reply-To: <53A27162.7070208@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2316 bytes --]

On 19-06-14 07:13, Richard Henderson wrote:
> On 05/19/2014 07:30 AM, Tom de Vries wrote:
>> +  for (insn = get_insns (); insn != NULL_RTX; insn = next_insn (insn))
>> +    {
>> +      HARD_REG_SET insn_used_regs;
>> +
>> +      if (!NONDEBUG_INSN_P (insn))
>> +	continue;
>> +
>> +      find_all_hard_reg_sets (insn, &insn_used_regs, false);
>> +
>> +      if (CALL_P (insn)
>> +	  && !get_call_reg_set_usage (insn, &insn_used_regs, call_used_reg_set))
>> +	{
>> +	  CLEAR_HARD_REG_SET (node->function_used_regs);
>> +	  return;
>> +	}
>> +
>> +      IOR_HARD_REG_SET (node->function_used_regs, insn_used_regs);
>> +    }

<SNIP>

> Let's suppose that we've got a rather large function, with only local calls for
> which we can acquire usage.  Let's suppose that even one of those callees
> further calls something else, such that insn_used_regs == call_used_reg_set.
>
> We fill node->function_used_regs immediately, but keep scanning the rest of the
> large function.
>
>
>> +
>> +  /* Be conservative - mark fixed and global registers as used.  */
>> +  IOR_HARD_REG_SET (node->function_used_regs, fixed_reg_set);
>> +  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
>> +    if (global_regs[i])
>> +      SET_HARD_REG_BIT (node->function_used_regs, i);
>> +
>> +#ifdef STACK_REGS
>> +  /* Handle STACK_REGS conservatively, since the df-framework does not
>> +     provide accurate information for them.  */
>> +
>> +  for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++)
>> +    SET_HARD_REG_BIT (node->function_used_regs, i);
>> +#endif
>> +
>> +  node->function_used_regs_valid = 1;
>
> Wouldn't it be better to compare the collected function_used_regs; if it
> contains all of call_used_reg_set, decline to set function_used_regs_valid.
> That way, we'll early exit from the above loop whenever we see that we can't
> improve over the default call-clobber set.
>

Richard,

Agreed.  Attached patch implements this (on top of the minor rewrite of 
https://gcc.gnu.org/ml/gcc-patches/2014-06/msg01535.html ).

> Although perhaps function_used_regs_valid is no longer the best name in that
> case...
>

I think the name is still ok.  The field function_used_regs_valid just states 
that the function_used_regs field is valid and can be used.


OK for trunk if bootstrap and reg-test on x86_64 is ok ?

Thanks,
- Tom

[-- Attachment #2: 0007-Don-t-save-function_used_regs-if-it-contains-all-cal.patch --]
[-- Type: text/x-patch, Size: 707 bytes --]

2014-06-19  Tom de Vries  <tom@codesourcery.com>

	* final.c (collect_fn_hard_reg_usage): Don't save function_used_regs if
	it contains all call_used_regs.

diff --git a/gcc/final.c b/gcc/final.c
index e39930d..e67e84b 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -4795,6 +4795,11 @@ collect_fn_hard_reg_usage (void)
     SET_HARD_REG_BIT (function_used_regs, i);
 #endif
 
+  /* The information we have gathered is only interesting if it exposes a
+     register from the call_used_regs that is not used in this function.  */
+  if (hard_reg_set_subset_p (call_used_reg_set, function_used_regs))
+    return;
+
   node = cgraph_rtl_info (current_function_decl);
   gcc_assert (node != NULL);
 
-- 
1.9.1


  parent reply	other threads:[~2014-06-19 16:06 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-16 19:22 fuse-caller-save - hook format Tom de Vries
2014-04-16 19:47 ` Richard Sandiford
2014-04-16 21:23   ` Jeff Law
2014-04-17 15:21 ` Vladimir Makarov
2014-04-17 15:35   ` Richard Sandiford
2014-04-17 16:49     ` Vladimir Makarov
2014-04-22 15:18       ` Tom de Vries
2014-04-22 15:31         ` Richard Sandiford
2014-04-22 16:10           ` Tom de Vries
2014-04-22 16:23             ` Richard Sandiford
2014-04-22 17:15               ` Tom de Vries
2014-04-23  8:54                 ` Richard Earnshaw
2014-04-22 16:57         ` Add call_fusage_contains_non_callee_clobbers hook Tom de Vries
2014-04-23 15:16           ` Richard Sandiford
2014-04-24  7:23             ` Tom de Vries
2014-05-05 15:45               ` Vladimir Makarov
2014-04-23 10:49         ` -fuse-caller-save - Collect register usage information Tom de Vries
2014-04-23 15:10           ` Vladimir Makarov
2014-04-23 15:20           ` Richard Sandiford
2014-04-26 13:26             ` Tom de Vries
2014-05-12 13:28               ` [PING] " Tom de Vries
2014-05-17 10:52               ` Eric Botcazou
2014-05-19 14:30                 ` Tom de Vries
2014-05-20 16:36                   ` Eric Botcazou
2014-05-25  0:43                   ` Jan Hubicka
2014-05-28 22:42                   ` Bill Schmidt
2014-05-29  8:43                     ` Tom de Vries
2014-06-19  5:13                   ` Richard Henderson
2014-06-19 12:40                     ` Tom de Vries
2014-06-19 15:36                       ` Richard Henderson
2014-06-19 16:06                     ` Tom de Vries [this message]
2014-06-19 16:26                       ` Richard Henderson
2014-06-19 19:36                         ` Jan Hubicka
2014-06-19 19:45                           ` Richard Henderson
2014-07-13 12:18                             ` Tom de Vries
2014-07-13 13:25                               ` Jan Hubicka
2014-05-25  0:34               ` Jan Hubicka
2014-10-10 21:58           ` Mike Stump
2014-10-11 12:44             ` Eric Botcazou
2014-10-16 21:33               ` Tom de Vries
2014-10-16 21:54                 ` Eric Botcazou
2014-10-17 11:00                   ` Tom de Vries
2014-10-17 11:05                     ` Richard Biener
2014-10-17 15:51                       ` Jeff Law
2014-10-17 17:33                         ` Mike Stump
2014-10-17 19:53                     ` Eric Botcazou
2014-10-19 14:14                       ` Tom de Vries
2014-10-20 17:23                         ` Eric Botcazou
2014-10-16 22:10                 ` Mike Stump
2014-04-23 12:27         ` Add clobber_reg Tom de Vries
2014-04-24 15:01           ` Eric Botcazou
2014-04-23 13:20         ` Add post_expand_call_insn hook Tom de Vries
2014-04-24 15:31           ` Eric Botcazou
2014-04-29  9:04             ` Tom de Vries
2014-04-29 19:00               ` Richard Henderson
2014-04-29 23:48                 ` Tom de Vries
2014-04-25 13:20         ` -fuse-caller-save - Enable for MIPS Tom de Vries
2014-04-25 13:35           ` Richard Sandiford
2014-04-26 12:15             ` Tom de Vries
2014-04-27 10:30               ` Richard Sandiford
2014-04-27 23:49                 ` Tom de Vries
2014-04-28 10:29                   ` Richard Sandiford
2014-04-28 10:48                     ` Tom de Vries
2014-04-28 12:14                       ` Tom de Vries
2014-04-28 15:01                         ` Richard Sandiford
2014-04-28 14:55                       ` Richard Sandiford

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=53A30A69.7060905@mentor.com \
    --to=tom_devries@mentor.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=rdsandiford@googlemail.com \
    --cc=rth@redhat.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).