public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [Ping] [patch 0/3] New macro PREFERRED_RENAME_CLASS
Date: Tue, 09 Nov 2010 15:33:00 -0000	[thread overview]
Message-ID: <4CD9688C.8080101@codesourcery.com> (raw)
In-Reply-To: <201011091016.07504.ebotcazou@adacore.com>

On 11/09/2010 05:16 PM, Eric Botcazou wrote:
>> Currently, we iterate registers from low to high, and resulting
>> "preferring" high registers in each iteration.  Generally speaking, low
>> registers are "better", at least not worse, than high register, in terms
>> of code size or other metrics.  Why can't we reverse the order of
>> iteration?
> 
> Generally we avoid changing things if we cannot prove that there is a benefit 
> in doing so.  The compiler supports many architectures and you never really 
> know how a change behaves with each of them in particular.  Why would "low" 
> registers be universally better than "high" registers?
> 

Eric,
I can't prove that statement.

>> I don't see any ports do something specific to this iteration order.  I run
>> regression test on ARM, X86, X86_64, and don't see any regressions if
>> iteration order is reversed.  So I assume that it is not harmful to reverse
>> the iteration order to all ports, and useful to some ports, not only to ARM.
> 
> Testing on a couple of architectures isn't really sufficient to conclude here 
> in my opinion, so I wouldn't change this, unless specifically requested by 
> the presence of the hook.
> 

OK, I agree on this.

>> The goal of this piece of work is to assign low registers to mostly used
>> registers, so that code size can be reduced.  There is similar feature
>> on X86_64, pointed out by HJ.  In order to achieve this, we need 1) a
>> target hook to prefer low register class, 2) iterate registers from high
>> to low.
> 
> OK, but AFAICS the target hook as currently written isn't a "preference" thing 
> but an "exclusion" thing, i.e. all the non-LO_REGS will be excluded and not 
> only disparaged for GENERAL_REGS.  So, once non-LO_REGS are excluded, why 
> changing the iteration order?  Does the iteration order within the LO_REGS 
> class matter as well for the ARM?
> 

No, order doesn't matter within the LO_REGS class.

>> Yes, the situation you described is correct, but this situation is *not*
>> popular, because we've sorted du_head linked list, and assign mostly
>> used registers to low registers.  I can't give you a quantitative
>> measurements, but code size of some programs is reduced.
> 
> OK, on the ARM, but what about the 20 other architectures that may want to 
> paramerize the pass too?
> 

That is a good question, and I have no answer to it. :)

>> I thought of target hook like this before, but this can't solve the
>> issue of iteration order.  If different ports need different iteration
>> order, we have to provide a target hook for this.
> 
> This can solve the iteration order like so: you compute a "representative" 
> class for the renaming chain, and then you iterate over N, call the hook, and 
> iterate over the contents of the class it returns.
> 

I consider this patch again today, and here is a design like this,

  1.  Don't change iteration order,
  2.  Define new hook preferred_rename_register_p,
  DEFHOOK
  (preferred_renaming_register_p,
  "True if hardware register is what target prefers to rename",
  bool,
  (int),
  preferred_renaming_register_false)

  3.  Call this hook like this,
for (new_reg = 0; new_reg < FIRST_PSEUDO_REGISTER; new_reg++)
{
  ...
  if (! tmp)
    {
      if (tick[best_new_reg] > tick[new_reg])
        {
          best_new_reg = new_reg;
          best_nregs = nregs;
	
+	  if (best_new_reg != reg /* Have better choice.  */
+             /* If this register is what target prefers to rename,
break the loop,  and not skip this register.  */
+	      && targetm.preferred_rename_register_p(best_new_reg))
+	        break;
	 }
    }
}

  4.  On ARM, preferred_renaming_register_p returns true if target is
thumb2 and register's class is LO_REGS.  Other ports can define their
own preference here.

This design has some advantages against last one,
  1.  More target-independent,
  2.  We prefer register rather than exclude register.

What do you think of this design?

-- 
Yao (齐尧)

  reply	other threads:[~2010-11-09 15:28 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04  5:31 Yao Qi
2010-11-05  9:53 ` Eric Botcazou
2010-11-05 16:08   ` Yao Qi
2010-11-08 12:52     ` Eric Botcazou
2010-11-08 15:11       ` Yao Qi
2010-11-09  9:26         ` Eric Botcazou
2010-11-09 15:33           ` Yao Qi [this message]
2010-11-11 17:40             ` Eric Botcazou
2010-11-11 18:01               ` Eric Botcazou
2010-12-01 16:48               ` Yao Qi
2010-12-03 10:58                 ` Eric Botcazou
2010-12-03 14:08                   ` Yao Qi
2010-12-06 18:27                     ` Eric Botcazou
2010-12-06 20:34                       ` Joseph S. Myers
2010-12-06 20:35                         ` Eric Botcazou
2010-12-06 20:39                           ` Joseph S. Myers
2010-12-06 22:02                             ` Eric Botcazou
2010-12-07 12:35                       ` Yao Qi
2010-12-13 13:10                         ` Eric Botcazou
2011-01-02 17:43                           ` Eric Botcazou
2010-12-13 19:43                     ` ARM bootstrap failure (Re: [Ping] [patch 0/3] New macro PREFERRED_RENAME_CLASS) Ulrich Weigand
2010-12-13 20:46                       ` Ulrich Weigand
2010-12-04 16:06                   ` [Ping] [patch 0/3] New macro PREFERRED_RENAME_CLASS Daniel Jacobowitz
2010-12-06 11:11                     ` Eric Botcazou
2010-11-20 12:05 ` Eric Botcazou
2010-11-23 12:06   ` Yao Qi

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=4CD9688C.8080101@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=ebotcazou@adacore.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).