From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30459 invoked by alias); 3 Sep 2014 16:58:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 30445 invoked by uid 89); 3 Sep 2014 16:58:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 Sep 2014 16:58:54 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XPDtL-0003mV-Et from Tom_deVries@mentor.com ; Wed, 03 Sep 2014 09:58:46 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Wed, 3 Sep 2014 17:58:42 +0100 Message-ID: <540748BE.9070205@mentor.com> Date: Wed, 03 Sep 2014 16:58:00 -0000 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Ulrich Weigand CC: Vladimir Makarov , Steven Bosscher , "gcc-patches@gcc.gnu.org" , Radovan Obradovic Subject: Re: [PATCH][IRA] Analysis of register usage of functions for usage by IRA. References: <201409011641.s81GfSmK004385@d06av02.portsmouth.uk.ibm.com> In-Reply-To: <201409011641.s81GfSmK004385@d06av02.portsmouth.uk.ibm.com> Content-Type: multipart/mixed; boundary="------------060500050005020103010802" X-SW-Source: 2014-09/txt/msg00253.txt.bz2 --------------060500050005020103010802 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2647 On 01-09-14 18:41, Ulrich Weigand wrote: > Tom de Vries wrote: > >> * ira-costs.c (ira_tune_allocno_costs): Use >> ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS to adjust costs. > > In debugging PR 53864 on s390x-linux, I ran into a weird change in behavior > that occurs when the following part of this patch was checked in: > >> - if (ira_hard_reg_set_intersection_p (regno, mode, call_used_reg_set) >> - || HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) >> - cost += (ALLOCNO_CALL_FREQ (a) >> - * (ira_memory_move_cost[mode][rclass][0] >> - + ira_memory_move_cost[mode][rclass][1])); >> + crossed_calls_clobber_regs >> + = &(ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS (a)); >> + if (ira_hard_reg_set_intersection_p (regno, mode, >> + *crossed_calls_clobber_regs)) >> + { >> + if (ira_hard_reg_set_intersection_p (regno, mode, >> + call_used_reg_set) >> + || HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) >> + cost += (ALLOCNO_CALL_FREQ (a) >> + * (ira_memory_move_cost[mode][rclass][0] >> + + ira_memory_move_cost[mode][rclass][1])); >> #ifdef IRA_HARD_REGNO_ADD_COST_MULTIPLIER >> - cost += ((ira_memory_move_cost[mode][rclass][0] >> - + ira_memory_move_cost[mode][rclass][1]) >> - * ALLOCNO_FREQ (a) >> - * IRA_HARD_REGNO_ADD_COST_MULTIPLIER (regno) / 2); >> + cost += ((ira_memory_move_cost[mode][rclass][0] >> + + ira_memory_move_cost[mode][rclass][1]) >> + * ALLOCNO_FREQ (a) >> + * IRA_HARD_REGNO_ADD_COST_MULTIPLIER (regno) / 2); >> #endif >> + } > > Before that patch, this code would penalize all call-clobbered registers > (if the alloca is used across a call), and it would penalize *all* registers > in a target-dependent way if IRA_HARD_REGNO_ADD_COST_MULTIPLIER is defined; > the latter is completely independent of the presence of any calls. > > However, after that patch, the IRA_HARD_REGNO_ADD_COST_MULTIPLIER penalty > is only applied for registers clobbered by calls in this function. This > seems a completely unrelated change, and looks just wrong to me ... > > Was this done intentionally or is this just an oversight? > Ulrich, thanks for noticing this. I agree, this looks wrong, and is probably an oversight. [ It seems that s390 is the only target defining IRA_HARD_REGNO_ADD_COST_MULTIPLIER, so this problem didn't show up on any other target. ] I think attached patch fixes it. I've build the patch and ran the fuse-caller-save tests, and I'm currently bootstrapping and reg-testing it on x86_64. Can you check whether this patches fixes the issue for s390 ? Thanks, - Tom > Bye, > Ulrich > --------------060500050005020103010802 Content-Type: text/x-patch; name="0001-Fix-IRA_HARD_REGNO_ADD_COST_MULTIPLIER-in-ira_tune_a.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Fix-IRA_HARD_REGNO_ADD_COST_MULTIPLIER-in-ira_tune_a.pa"; filename*1="tch" Content-length: 1456 diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c index 774a958..57239f5 100644 --- a/gcc/ira-costs.c +++ b/gcc/ira-costs.c @@ -2217,21 +2217,19 @@ ira_tune_allocno_costs (void) crossed_calls_clobber_regs = &(ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS (a)); if (ira_hard_reg_set_intersection_p (regno, mode, - *crossed_calls_clobber_regs)) - { - if (ira_hard_reg_set_intersection_p (regno, mode, + *crossed_calls_clobber_regs) + && (ira_hard_reg_set_intersection_p (regno, mode, call_used_reg_set) - || HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) - cost += (ALLOCNO_CALL_FREQ (a) - * (ira_memory_move_cost[mode][rclass][0] - + ira_memory_move_cost[mode][rclass][1])); + || HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))) + cost += (ALLOCNO_CALL_FREQ (a) + * (ira_memory_move_cost[mode][rclass][0] + + ira_memory_move_cost[mode][rclass][1])); #ifdef IRA_HARD_REGNO_ADD_COST_MULTIPLIER - cost += ((ira_memory_move_cost[mode][rclass][0] - + ira_memory_move_cost[mode][rclass][1]) - * ALLOCNO_FREQ (a) - * IRA_HARD_REGNO_ADD_COST_MULTIPLIER (regno) / 2); + cost += ((ira_memory_move_cost[mode][rclass][0] + + ira_memory_move_cost[mode][rclass][1]) + * ALLOCNO_FREQ (a) + * IRA_HARD_REGNO_ADD_COST_MULTIPLIER (regno) / 2); #endif - } if (INT_MAX - cost < reg_costs[j]) reg_costs[j] = INT_MAX; else -- 1.9.1 --------------060500050005020103010802--