From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77544 invoked by alias); 4 Dec 2018 15:11:39 -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 77525 invoked by uid 89); 4 Dec 2018 15:11:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,KAM_NUMSUBJECT,KAM_SHORT,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=frequency 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 ESMTP; Tue, 04 Dec 2018 15:11:36 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 411E73091793 for ; Tue, 4 Dec 2018 15:11:35 +0000 (UTC) Received: from [10.10.120.241] (ovpn-120-241.rdu2.redhat.com [10.10.120.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 848C75D78F for ; Tue, 4 Dec 2018 15:11:34 +0000 (UTC) From: Vladimir Makarov Subject: patch to fix PR88282 To: "gcc-patches@gcc.gnu.org" Message-ID: Date: Tue, 04 Dec 2018 15:11:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------EEE2E2F511D4B3D952303062" X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg00204.txt.bz2 This is a multi-part message in MIME format. --------------EEE2E2F511D4B3D952303062 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 200   The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88282   The patch was successfully bootstrapped and tested on x86/x86-64/ppc64/aarch64.   Committed as rev. 266784. --------------EEE2E2F511D4B3D952303062 Content-Type: text/x-patch; name="pr88282.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr88282.patch" Content-length: 3438 Index: ChangeLog =================================================================== --- ChangeLog (revision 266783) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2018-12-04 Vladimir Makarov + + PR target/88282 + * ira-costs.c (exec): Try bigger class to use smaller register + move cost. + 2018-12-04 Michael Ploujnikov PR ipa/88297 Index: ira-costs.c =================================================================== --- ira-costs.c (revision 266678) +++ ira-costs.c (working copy) @@ -1314,28 +1314,50 @@ record_operand_costs (rtx_insn *insn, en machine_mode mode = GET_MODE (SET_SRC (set)); cost_classes_t cost_classes_ptr = regno_cost_classes[regno]; enum reg_class *cost_classes = cost_classes_ptr->classes; - reg_class_t rclass, hard_reg_class, pref_class; + reg_class_t rclass, hard_reg_class, pref_class, bigger_hard_reg_class; int cost, k; + move_table *move_costs; bool dead_p = find_regno_note (insn, REG_DEAD, REGNO (src)); ira_init_register_move_cost_if_necessary (mode); + move_costs = ira_register_move_cost[mode]; hard_reg_class = REGNO_REG_CLASS (other_regno); + bigger_hard_reg_class = ira_pressure_class_translate[hard_reg_class]; + if (bigger_hard_reg_class == NO_REGS + && (other_regno == STACK_POINTER_REGNUM +#ifdef STATIC_CHAIN_REGNUM + || other_regno == STATIC_CHAIN_REGNUM +#endif + || other_regno == FRAME_POINTER_REGNUM + || other_regno == HARD_FRAME_POINTER_REGNUM)) + bigger_hard_reg_class = GENERAL_REGS; /* Target code may return any cost for mode which does not fit the the hard reg class (e.g. DImode for AREG on i386). Check this and use a bigger class to get the right cost. */ if (! ira_hard_reg_in_set_p (other_regno, mode, reg_class_contents[hard_reg_class])) - hard_reg_class = ira_pressure_class_translate[hard_reg_class]; + hard_reg_class = bigger_hard_reg_class; i = regno == (int) REGNO (src) ? 1 : 0; for (k = cost_classes_ptr->num - 1; k >= 0; k--) { rclass = cost_classes[k]; - cost = ((i == 0 - ? ira_register_move_cost[mode][hard_reg_class][rclass] - : ira_register_move_cost[mode][rclass][hard_reg_class]) - * frequency); - op_costs[i]->cost[k] = cost; + cost = (i == 0 + ? move_costs[hard_reg_class][rclass] + : move_costs[rclass][hard_reg_class]); + /* Target code might define wrong big costs for smaller + reg classes or reg classes containing only fixed hard + regs. Try a bigger class. */ + if (bigger_hard_reg_class != hard_reg_class) + { + int cost2 = (i == 0 + ? move_costs[bigger_hard_reg_class][rclass] + : move_costs[rclass][bigger_hard_reg_class]); + if (cost2 < cost) + cost = cost2; + } + + op_costs[i]->cost[k] = cost * frequency; /* If we have assigned a class to this allocno in our first pass, add a cost to this alternative corresponding to what we would add if this allocno @@ -1350,7 +1372,7 @@ record_operand_costs (rtx_insn *insn, en else if (ira_reg_class_intersect[pref_class][rclass] == NO_REGS) op_costs[i]->cost[k] - += (ira_register_move_cost[mode][pref_class][rclass] + += (move_costs[pref_class][rclass] * frequency); } /* If this insn is a single set copying operand 1 to --------------EEE2E2F511D4B3D952303062--