From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27905 invoked by alias); 1 Aug 2017 00:05:04 -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 27864 invoked by uid 89); 1 Aug 2017 00:05:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=originals, Hx-languages-length:2707, 193 X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Aug 2017 00:05:02 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 56DF41C0809; Mon, 31 Jul 2017 23:25:27 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH 3/5] combine: Use insn_cost instead of pattern_cost everywhere Date: Tue, 01 Aug 2017 00:05:00 -0000 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00001.txt.bz2 This changes combine to always use insn_cost, not pattern_cost. I don't intend to commit it like this: it calls recog more often than necessary, and it is very ugly (no, don't look at it). But it's good enough to test things with. --- gcc/combine.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/gcc/combine.c b/gcc/combine.c index aadd328..d0bd4d3 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -856,7 +856,7 @@ combine_validate_cost (rtx_insn *i0, rtx_insn *i1, rtx_insn *i2, rtx_insn *i3, int new_i2_cost, new_i3_cost; int old_cost, new_cost; - /* Lookup the original insn_rtx_costs. */ + /* Lookup the original insn_costs. */ i2_cost = INSN_COST (i2); i3_cost = INSN_COST (i3); @@ -888,11 +888,23 @@ combine_validate_cost (rtx_insn *i0, rtx_insn *i1, rtx_insn *i2, rtx_insn *i3, old_cost -= i1_cost; - /* Calculate the replacement pattern_costs. */ - new_i3_cost = pattern_cost (newpat, optimize_this_for_speed_p); + /* Calculate the replacement insn_costs. */ + rtx tmp = PATTERN (i3); + PATTERN (i3) = newpat; + int tmpi = INSN_CODE (i3); + INSN_CODE (i3) = -1; + new_i3_cost = insn_cost (i3, optimize_this_for_speed_p); + PATTERN (i3) = tmp; + INSN_CODE (i3) = tmpi; if (newi2pat) { - new_i2_cost = pattern_cost (newi2pat, optimize_this_for_speed_p); + tmp = PATTERN (i2); + PATTERN (i2) = newi2pat; + tmpi = INSN_CODE (i2); + INSN_CODE (i2) = -1; + new_i2_cost = insn_cost (i2, optimize_this_for_speed_p); + PATTERN (i2) = tmp; + INSN_CODE (i2) = tmpi; new_cost = (new_i2_cost > 0 && new_i3_cost > 0) ? new_i2_cost + new_i3_cost : 0; } @@ -907,7 +919,14 @@ combine_validate_cost (rtx_insn *i0, rtx_insn *i1, rtx_insn *i2, rtx_insn *i3, int old_other_cost, new_other_cost; old_other_cost = INSN_COST (undobuf.other_insn); - new_other_cost = pattern_cost (newotherpat, optimize_this_for_speed_p); + tmp = PATTERN (undobuf.other_insn); + PATTERN (undobuf.other_insn) = newotherpat; + tmpi = INSN_CODE (undobuf.other_insn); + INSN_CODE (undobuf.other_insn) = -1; + new_other_cost = insn_cost (undobuf.other_insn, + optimize_this_for_speed_p); + PATTERN (undobuf.other_insn) = tmp; + INSN_CODE (undobuf.other_insn) = tmpi; if (old_other_cost > 0 && new_other_cost > 0) { old_cost += old_other_cost; @@ -4081,7 +4100,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, } } - /* Only allow this combination if insn_rtx_costs reports that the + /* Only allow this combination if insn_cost reports that the replacement instructions are cheaper than the originals. */ if (!combine_validate_cost (i0, i1, i2, i3, newpat, newi2pat, other_pat)) { -- 1.9.3