From patchwork Mon Jun 19 13:46:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard Earnshaw \(lists\)" X-Patchwork-Id: 105835 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp862703obh; Mon, 19 Jun 2017 06:47:26 -0700 (PDT) X-Received: by 10.84.229.69 with SMTP id d5mr5051533pln.197.1497880046728; Mon, 19 Jun 2017 06:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497880046; cv=none; d=google.com; s=arc-20160816; b=OEJXmclKEAz8zKX+jZhhW6SxsFuNhCgI+VHbWKtisWQ1cvOcchVLm7Fyk3AbR021S6 dS3k+4vRV786nhtgLz4Ar31VQ0dNYC3ku5AHj5Jovp11075VS73qUbSJzmR0M6A43ITF Xus8B83U9gBl1yCH4LFR0mUK9/Sth8hzYYI5pNwMrfCYcxNd+kiRVruv+a3PbYdTyFPE /bTxZFZYej8HiOFhwrzePkQLqRb8QnehBOFv6LUKjtjd91XwAPlr+Xlo3+eFn1kQbaeY Cc0yRn+pF3tKEUQ2gUM8NrB3/mUDqnLGY2b3RD9GNKfr5MEmAxK+rwYzglOch4fMBUqU LbSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:date:message-id:subject:from:cc:to :delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=zIqD0iExwyJs5laioVH0yM9k9Y/bi35QFDSjn9oBfXc=; b=VxNXv4ZgDsBz4qnu4FXCfqikLksagQxlOBWgnrZcT8RHa56F2T6BCHw91Atj3/K6GE EU2ijaA2MizvuJe7t0GHXr1ARzCB7vfMsWV4jybyRBG5NbEChGtnJAfQjLjPtru+31O6 j0doVTTcWxrFa1KF5LUQo9AjO7y8oE68AgFBdZN9WS36ow4wB7RIFJZnDqjzpJP54TyB ce0kurJq0sh+7aC1/N6p8Zwo/gC+dYHEfVlTeQJxCYjmqFINcmEWAutLvCXM14kh5wzu wph56ZsW1lLMPF7OLEmHb0m+t2nYoV1dkRr9cySO+yuBaU8MXRG/HlcxO9f3DIBfu/C0 0sGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=i1MMNsol; spf=pass (google.com: domain of gcc-patches-return-456212-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-456212-patch=linaro.org@gcc.gnu.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b35si4296489plh.638.2017.06.19.06.47.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 06:47:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-456212-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=i1MMNsol; spf=pass (google.com: domain of gcc-patches-return-456212-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-456212-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=OiuNfWSPowVDMO4GOlqJ/e/J2vfDgsL4U7fnE09Nd8+37yn/yf HneXVtWLNh0EupNISlUZ8ZceOxOqsoYMY8H143aMG7ILf0wHcbebzQcw5K3fyLzf 9EmWtrOeaHd4JYdQGdVdf8YqpgJFX3JHIFYxXeVrhbQB4dW73U5p4hVjk= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=87adsKmdo3m3sr8jCW9K0IXB3eU=; b=i1MMNsol6GKPSQrEG2Jy UsTzKC6CUYovLGwm7hwv6N+hkbS2Nt11D3OWlJIQDvV7xHFUsJEaVvT3cDOnuHfj nDWySe68Tp42Xy87HaT0S0yoMEro5xy4ZQas2R983FhXsPWqYTphYpU2e6wpU/lt N4cYo1+Ifat95OkgaYilOBo= Received: (qmail 83752 invoked by alias); 19 Jun 2017 13:47:04 -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 79178 invoked by uid 89); 19 Jun 2017 13:47:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=costing, infinitely, Hx-languages-length:2113 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; Mon, 19 Jun 2017 13:47:00 +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 7A295344; Mon, 19 Jun 2017 06:47:03 -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 CAA713F41F; Mon, 19 Jun 2017 06:47:02 -0700 (PDT) To: gcc-patches Cc: Segher Boessenkool From: "Richard Earnshaw (lists)" Subject: [rtlanal] Do a better job of costing parallel sets containing flag-setting operations. Message-ID: <66275bc9-7d97-b990-4c86-2de1f4a6a2fa@arm.com> Date: Mon, 19 Jun 2017 14:46:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 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? R. 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; }