From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58275 invoked by alias); 30 Jun 2017 09:03:20 -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 58261 invoked by uid 89); 30 Jun 2017 09:03:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_SORBS_SPAM,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=costing, allowing X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Jun 2017 09:03:18 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6483380D; Fri, 30 Jun 2017 02:03:16 -0700 (PDT) Received: from e105689-lin.cambridge.arm.com (e105689-lin.cambridge.arm.com [10.2.207.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E61B43F4FF; Fri, 30 Jun 2017 02:03:15 -0700 (PDT) Subject: Re: [rtlanal] Do a better job of costing parallel sets containing flag-setting operations. From: "Richard Earnshaw (lists)" To: gcc-patches References: <66275bc9-7d97-b990-4c86-2de1f4a6a2fa@arm.com> Message-ID: Date: Fri, 30 Jun 2017 09:03:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <66275bc9-7d97-b990-4c86-2de1f4a6a2fa@arm.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2017-06/txt/msg02363.txt.bz2 On 19/06/17 14:46, Richard Earnshaw (lists) wrote: > Many parallel set insns are of the form of a single set that also sets > the condition code flags. In this case the cost of such an insn is > normally the cost of the part that doesn't set the flags, since updating > the condition flags is simply a side effect. > > At present all such insns are treated as having unknown cost (ie 0) and > combine assumes that such insns are infinitely more expensive than any > other insn sequence with a non-zero cost. > > This patch addresses this problem by allowing insn_rtx_cost to ignore > the condition setting part of a PARALLEL iff there is exactly one > comparison set and one non-comparison set. If the only set operation is > a comparison we still use that as the basis of the insn cost. > > * rtlanal.c (insn_rtx_cost): If a parallel contains exactly one > comparison set and one other set, use the cost of the > non-comparison set. > > Bootstrapped on aarch64-none-linuxgnu > > OK? > Ping? R. > R. > > > insn-costs.patch > > > diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c > index d9f57c3..5cae793 100644 > --- a/gcc/rtlanal.c > +++ b/gcc/rtlanal.c > @@ -5260,23 +5260,41 @@ insn_rtx_cost (rtx pat, bool speed) > int i, cost; > rtx set; > > - /* Extract the single set rtx from the instruction pattern. > - We can't use single_set since we only have the pattern. */ > + /* Extract the single set rtx from the instruction pattern. We > + can't use single_set since we only have the pattern. We also > + consider PARALLELs of a normal set and and a single comparison. > + In that case we use the cost of the non-comparison SET operation, > + which is most-likely to be the real cost of this operation. */ > if (GET_CODE (pat) == SET) > set = pat; > else if (GET_CODE (pat) == PARALLEL) > { > set = NULL_RTX; > + rtx comparison = NULL_RTX; > + > for (i = 0; i < XVECLEN (pat, 0); i++) > { > rtx x = XVECEXP (pat, 0, i); > if (GET_CODE (x) == SET) > { > - if (set) > - return 0; > - set = x; > + if (GET_CODE (SET_SRC (x)) == COMPARE) > + { > + if (comparison) > + return 0; > + comparison = x; > + } > + else > + { > + if (set) > + return 0; > + set = x; > + } > } > } > + > + if (!set && comparison) > + set = comparison; > + > if (!set) > return 0; > } >