From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13466 invoked by alias); 15 Dec 2004 06:56:35 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 13334 invoked from network); 15 Dec 2004 06:56:20 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 15 Dec 2004 06:56:20 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id iBF6uKWT013332; Wed, 15 Dec 2004 01:56:20 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id iBF6uKr18417; Wed, 15 Dec 2004 01:56:20 -0500 Received: from livre.redhat.lsd.ic.unicamp.br (vpn50-63.rdu.redhat.com [172.16.50.63]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id iBF6uIbo032080; Wed, 15 Dec 2004 01:56:19 -0500 Received: from livre.redhat.lsd.ic.unicamp.br (livre.redhat.lsd.ic.unicamp.br [127.0.0.1]) by livre.redhat.lsd.ic.unicamp.br (8.13.1/8.13.1) with ESMTP id iBF6uHUV011360; Wed, 15 Dec 2004 04:56:17 -0200 Received: (from aoliva@localhost) by livre.redhat.lsd.ic.unicamp.br (8.13.1/8.13.1/Submit) id iBF6uEZT011328; Wed, 15 Dec 2004 04:56:15 -0200 To: Richard Henderson Cc: Bernd Schmidt , gcc@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [RFC] avoiding too narrow register classes in reload References: <20041214020635.GA16249@redhat.com> <20041214223127.GE19197@redhat.com> From: Alexandre Oliva Organization: Red Hat Global Engineering Services Compiler Team Date: Wed, 15 Dec 2004 06:56:00 -0000 In-Reply-To: <20041214223127.GE19197@redhat.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SW-Source: 2004-12/txt/msg00561.txt.bz2 --=-=-= Content-length: 693 On Dec 14, 2004, Richard Henderson wrote: > On Tue, Dec 14, 2004 at 07:20:10PM -0200, Alexandre Oliva wrote: >> I realize the patch introduces some possibly-significant semantic >> changes, in that NO_REGS is now regarded as a SMALL_REGISTER_CLASS_P > I think that is indeed a surprising result. >> Does it make sense to narrow the >> predicate to hold only for non-empty classes, and adjust the >> one-before-last hunk, that uses the negated predicate in a way that >> requires it to hold for empty classes? > Please. Here's the revised patch. Bootstrapped on x86_64-linux-gnu, regtesting will still take a while to complete. Ok to install if no regressions show up? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=reload-small-regclass-likely-spilled-take2.patch Content-length: 4232 Index: gcc/ChangeLog from Alexandre Oliva * 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 02:20:54 -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 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 [(int)(C)] == 1 \ + || (reg_class_size [(int)(C)] >= 1 && CLASS_LIKELY_SPILLED_P (C))) + /* 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)) { @@ -1768,8 +1775,7 @@ combine_reloads (void) rld[output_reload].out)))) && ! reload_inner_reg_of_subreg (rld[i].in, rld[i].inmode, rld[i].when_needed != RELOAD_FOR_INPUT) - && (reg_class_size[(int) rld[i].class] - || SMALL_REGISTER_CLASSES) + && (reg_class_size[(int) rld[i].class] || SMALL_REGISTER_CLASSES) /* We will allow making things slightly worse by combining an input and an output, but no worse than that. */ && (rld[i].when_needed == RELOAD_FOR_INPUT @@ -3484,7 +3490,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])) @@ -3542,7 +3549,8 @@ find_reloads (rtx insn, int replace, int { /* If the output is in a single-reg class, it's costly to reload it, so reload the input instead. */ - if (reg_class_size[this_alternative[i]] == 1 + if (reg_class_size[this_alternative[i]] > 0 + && SMALL_REGISTER_CLASS_P (this_alternative[i]) && (REG_P (recog_data.operand[j]) || GET_CODE (recog_data.operand[j]) == SUBREG)) { --=-=-= Content-length: 188 -- 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} --=-=-=--