From: Alexandre Oliva <aoliva@redhat.com>
To: Richard Henderson <rth@redhat.com>
Cc: Bernd Schmidt <bernds_cb1@t-online.de>,
gcc@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [RFC] avoiding too narrow register classes in reload
Date: Wed, 15 Dec 2004 20:07:00 -0000 [thread overview]
Message-ID: <or6533s4uc.fsf@livre.redhat.lsd.ic.unicamp.br> (raw)
In-Reply-To: <20041215080932.GB20219@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 849 bytes --]
On Dec 15, 2004, Richard Henderson <rth@redhat.com> wrote:
> On Wed, Dec 15, 2004 at 04:56:08AM -0200, Alexandre Oliva wrote:
>> * reload.c (SMALL_REGISTER_CLASS_P): New.
>> (push_secondary_reload, find_reusable_reload, find_reloads): Use
>> it instead of testing only the class size.
> Ok, except,
> We no longer have to cater to broken K&R compilers that refuse to
> index arrays by enums. Kill the casts.
Ok
>> - if (reg_class_size[this_alternative[i]] == 1
>> + if (reg_class_size[this_alternative[i]] > 0
>> + && SMALL_REGISTER_CLASS_P (this_alternative[i])
> reg_class_size check redundant with SMALL_REGISTER_CLASS_P.
I thought I'd leave it in for, like, documentation purposes, just in
case someone reworks SMALL_REGISTER_CLASS_P such that it can match
even for 0-sized classes, but fine. Here's what I'm checking in.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: reload-small-regclass-likely-spilled-take3.patch --]
[-- Type: text/x-patch, Size: 3821 bytes --]
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* reload.c (SMALL_REGISTER_CLASS_P): New.
(push_secondary_reload, find_reusable_reload, find_reloads): Use
it instead of testing only the class size.
Index: gcc/reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.260
diff -u -p -r1.260 reload.c
--- gcc/reload.c 7 Dec 2004 01:14:40 -0000 1.260
+++ gcc/reload.c 15 Dec 2004 20:05:08 -0000
@@ -113,6 +113,13 @@ a register with any other reload. */
(CONSTANT_P (X) \
&& GET_CODE (X) != HIGH \
&& !targetm.cannot_force_const_mem (X))
+
+/* True if C is a non-empty register class that has too few registers
+ to be safely used as a reload target class. */
+#define SMALL_REGISTER_CLASS_P(C) \
+ (reg_class_size [(C)] == 1 \
+ || (reg_class_size [(C)] >= 1 && CLASS_LIKELY_SPILLED_P (C)))
+
\f
/* All reloads of the current insn are recorded here. See reload.h for
comments. */
@@ -443,7 +450,7 @@ push_secondary_reload (int in_p, rtx x,
== CODE_FOR_nothing))
|| (! in_p &&(rld[t_reload].secondary_out_icode
== CODE_FOR_nothing)))
- && (reg_class_size[(int) t_class] == 1 || SMALL_REGISTER_CLASSES)
+ && (SMALL_REGISTER_CLASS_P (t_class) || SMALL_REGISTER_CLASSES)
&& MERGABLE_RELOADS (secondary_type,
rld[t_reload].when_needed,
opnum, rld[t_reload].opnum))
@@ -501,7 +508,7 @@ push_secondary_reload (int in_p, rtx x,
|| (! in_p && rld[s_reload].secondary_out_reload == t_reload))
&& ((in_p && rld[s_reload].secondary_in_icode == t_icode)
|| (! in_p && rld[s_reload].secondary_out_icode == t_icode))
- && (reg_class_size[(int) class] == 1 || SMALL_REGISTER_CLASSES)
+ && (SMALL_REGISTER_CLASS_P (class) || SMALL_REGISTER_CLASSES)
&& MERGABLE_RELOADS (secondary_type, rld[s_reload].when_needed,
opnum, rld[s_reload].opnum))
{
@@ -755,7 +762,7 @@ find_reusable_reload (rtx *p_in, rtx out
|| (out != 0 && MATCHES (rld[i].out, out)
&& (in == 0 || rld[i].in == 0 || MATCHES (rld[i].in, in))))
&& (rld[i].out == 0 || ! earlyclobber_operand_p (rld[i].out))
- && (reg_class_size[(int) class] == 1 || SMALL_REGISTER_CLASSES)
+ && (SMALL_REGISTER_CLASS_P (class) || SMALL_REGISTER_CLASSES)
&& MERGABLE_RELOADS (type, rld[i].when_needed, opnum, rld[i].opnum))
return i;
@@ -780,7 +787,7 @@ find_reusable_reload (rtx *p_in, rtx out
&& GET_RTX_CLASS (GET_CODE (in)) == RTX_AUTOINC
&& MATCHES (XEXP (in, 0), rld[i].in)))
&& (rld[i].out == 0 || ! earlyclobber_operand_p (rld[i].out))
- && (reg_class_size[(int) class] == 1 || SMALL_REGISTER_CLASSES)
+ && (SMALL_REGISTER_CLASS_P (class) || SMALL_REGISTER_CLASSES)
&& MERGABLE_RELOADS (type, rld[i].when_needed,
opnum, rld[i].opnum))
{
@@ -3484,7 +3491,8 @@ find_reloads (rtx insn, int replace, int
if (! win && ! did_match
&& this_alternative[i] != (int) NO_REGS
&& GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD
- && reg_class_size[(int) preferred_class[i]] > 1)
+ && reg_class_size [(int) preferred_class[i]] > 0
+ && ! SMALL_REGISTER_CLASS_P (preferred_class[i]))
{
if (! reg_class_subset_p (this_alternative[i],
preferred_class[i]))
@@ -3540,9 +3548,9 @@ find_reloads (rtx insn, int replace, int
&& !immune_p (recog_data.operand[j], recog_data.operand[i],
early_data))
{
- /* If the output is in a single-reg class,
+ /* If the output is in a non-empty few-regs class,
it's costly to reload it, so reload the input instead. */
- if (reg_class_size[this_alternative[i]] == 1
+ if (SMALL_REGISTER_CLASS_P (this_alternative[i])
&& (REG_P (recog_data.operand[j])
|| GET_CODE (recog_data.operand[j]) == SUBREG))
{
[-- Attachment #3: Type: text/plain, Size: 188 bytes --]
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
next prev parent reply other threads:[~2004-12-15 20:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-13 21:20 Alexandre Oliva
2004-12-14 2:06 ` Richard Henderson
2004-12-14 21:20 ` Alexandre Oliva
2004-12-14 22:31 ` Richard Henderson
2004-12-15 6:56 ` Alexandre Oliva
2004-12-15 8:09 ` Richard Henderson
2004-12-15 20:07 ` Alexandre Oliva [this message]
2004-12-16 14:14 ` Dave Korn
2004-12-14 16:22 ` Bernd Schmidt
2004-12-14 20:53 ` Alexandre Oliva
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=or6533s4uc.fsf@livre.redhat.lsd.ic.unicamp.br \
--to=aoliva@redhat.com \
--cc=bernds_cb1@t-online.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=gcc@gcc.gnu.org \
--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).