From patchwork Thu May 14 21:04:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 472524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3549E1400A0 for ; Fri, 15 May 2015 07:11:15 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=lIRPVHWB; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=pNPqD4zzdMtVsGXl4 0IHPMjWQ67N+ID1D2En+8nA1J/UQbjomcVFmUzjmfEbjFhPrYAV/kffdaUchZBD3 TzE18ufNY8IiPMC8Y3JTekex59MfwM//9+6Za69XCMTIWNHclsrRVMcTYZtq7Itf 9kc7dR3azCjPmMEZJ7W5DAE1TE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=auUj3JBd4ArypWXezQkcf+/ xSX0=; b=lIRPVHWB8rtUC+NDRt+9f9wCEqQjqhvvk3pQsrzh8VbjatrPNkdWyzs 2Mv6hE4YM6ZwPvLmzlgbq1GwZhXU5l+iVo9yBfcYu/nUH7ldTBAxLkzGLMnwxfaM DdxIDD5ISIQ/liSadA3E3dt10ncJObaYsCyu9BfpzKPshq2QdYmU= Received: (qmail 67279 invoked by alias); 14 May 2015 21:04:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 67266 invoked by uid 89); 14 May 2015 21:04:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 14 May 2015 21:04:29 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4EL4Ssg013551 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 14 May 2015 17:04:28 -0400 Received: from topor.usersys.redhat.com (unused-10-15-17-214.yyz.redhat.com [10.15.17.214]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4EL4RXB017935 for ; Thu, 14 May 2015 17:04:27 -0400 Message-ID: <55550DDB.8090907@redhat.com> Date: Thu, 14 May 2015 17:04:27 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: gcc-patches Subject: Re: patch for PR65862 References: <555508B6.7010104@redhat.com> In-Reply-To: <555508B6.7010104@redhat.com> X-IsSubscribed: yes On 05/14/2015 04:42 PM, Vladimir Makarov wrote: > The following patch is for solution of PR65862 > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65862 > > In some cases, calculations of reg class costs are not enough to > choose the right class. For example, in some cases you don't want to > start fp unit for energy saving considerations if you don't really > need it. Such case can occur when we have non-floating point mode > pseudo and calculation costs in ira says that it would be profitable > to put it in a floating point register. > > The full solution will need to add a hook to mips.c. I hope mips > maintainers will do that soon. > > The patch was bootstrapped on x86-64. > > Committed as rev. 223202. > > 2015-05-14 Vladimir Makarov > > PR rtl-optimization/65862 > * target.def (ira_change_pseudo_allocno_class): New hook. > * targhooks.c (default_ira_change_pseudo_allocno_class): Default > value of the hook. > * targhooks.h (default_ira_change_pseudo_allocno_class): New > extern > * doc/tm.texi.in (TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS): Add > the > hook. > * ira-costs.c (find_costs_and_classes): Call the hook and change > classes when it is necessary. > * doc/tm.texi: Update. > > Sorry, I missed to attach the patch. Here it is. Index: doc/tm.texi =================================================================== --- doc/tm.texi (revision 223198) +++ doc/tm.texi (working copy) @@ -2837,6 +2837,13 @@ as below: @end smallexample @end defmac +@deftypefn {Target Hook} reg_class_t TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS (int, @var{reg_class_t}) +A target hook which can change allocno class for given pseudo from + allocno class calculated by IRA. + + The default version of this target hook always returns given class. +@end deftypefn + @deftypefn {Target Hook} bool TARGET_LRA_P (void) A target hook which returns true if we use LRA instead of reload pass. It means that LRA was ported to the target. The default version of this target hook returns always false. @end deftypefn Index: doc/tm.texi.in =================================================================== --- doc/tm.texi.in (revision 223198) +++ doc/tm.texi.in (working copy) @@ -2475,6 +2475,8 @@ as below: @end smallexample @end defmac +@hook TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS + @hook TARGET_LRA_P @hook TARGET_REGISTER_PRIORITY Index: ira-costs.c =================================================================== --- ira-costs.c (revision 223198) +++ ira-costs.c (working copy) @@ -1636,7 +1636,7 @@ find_costs_and_classes (FILE *dump_file) int i, k, start, max_cost_classes_num; int pass; basic_block bb; - enum reg_class *regno_best_class; + enum reg_class *regno_best_class, new_class; init_recog (); regno_best_class @@ -1878,6 +1878,18 @@ find_costs_and_classes (FILE *dump_file) ira_assert (regno_aclass[i] != NO_REGS && ira_reg_allocno_class_p[regno_aclass[i]]); } + if ((new_class + = (reg_class) (targetm.ira_change_pseudo_allocno_class + (i, regno_aclass[i]))) != regno_aclass[i]) + { + regno_aclass[i] = new_class; + if (hard_reg_set_subset_p (reg_class_contents[new_class], + reg_class_contents[best])) + best = new_class; + if (hard_reg_set_subset_p (reg_class_contents[new_class], + reg_class_contents[alt_class])) + alt_class = new_class; + } if (pass == flag_expensive_optimizations) { if (best_cost > i_mem_cost) Index: target.def =================================================================== --- target.def (revision 223198) +++ target.def (working copy) @@ -4763,6 +4763,16 @@ This is currently used only by the C and tree, (tree type, tree expr), hook_tree_tree_tree_null) +/* Change pseudo allocno class calculated by IRA. */ +DEFHOOK +(ira_change_pseudo_allocno_class, + "A target hook which can change allocno class for given pseudo from\n\ + allocno class calculated by IRA.\n\ + \n\ + The default version of this target hook always returns given class.", + reg_class_t, (int, reg_class_t), + default_ira_change_pseudo_allocno_class) + /* Return true if we use LRA instead of reload. */ DEFHOOK (lra_p, Index: targhooks.c =================================================================== --- targhooks.c (revision 223198) +++ targhooks.c (working copy) @@ -914,6 +914,13 @@ default_branch_target_register_class (vo return NO_REGS; } +reg_class_t +default_ira_change_pseudo_allocno_class (int regno ATTRIBUTE_UNUSED, + reg_class_t cl) +{ + return cl; +} + extern bool default_lra_p (void) { Index: targhooks.h =================================================================== --- targhooks.h (revision 223198) +++ targhooks.h (working copy) @@ -140,6 +140,7 @@ extern rtx default_static_chain (const_t extern void default_trampoline_init (rtx, tree, rtx); extern int default_return_pops_args (tree, tree, int); extern reg_class_t default_branch_target_register_class (void); +extern reg_class_t default_ira_change_pseudo_allocno_class (int, reg_class_t); extern bool default_lra_p (void); extern int default_register_priority (int); extern bool default_register_usage_leveling_p (void);