From patchwork Wed Nov 23 19:01:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 83744 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp2880699obn; Wed, 23 Nov 2016 11:01:43 -0800 (PST) X-Received: by 10.98.152.3 with SMTP id q3mr4243250pfd.144.1479927703881; Wed, 23 Nov 2016 11:01:43 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 37si6546531plv.335.2016.11.23.11.01.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2016 11:01:43 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-442435-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; spf=pass (google.com: domain of gcc-patches-return-442435-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-442435-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 :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=mOJVCWt4W6QMrDMo5 UPAmKkH323lJeDaKtmjLbfnrEeOd7rE/WLFMYVa/uSQFKLkd39s+CdC/iCJm28eq HbJUwMHK7zlina+23EF1FYauBH7aU79rumN4vAc/blMKOR8BOMHuh1w0mqOqUKDl LZoLisakgBbGXvnmomuQwK6QNY= 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 :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=3svF0ViMRman08m8UwQTnnP gASg=; b=tnaDof7UN5tj8AT8c4ifbPf4q9dB2JMzPpKUl7Ecl3HmA1wvT63BKyg U81oi8ewdNCYGKCbMw8TsGAgZdzivLkLvc9xzyRx0a68coZl//x56v/qiICX6i/H wTRgwUZIYvPxvmZi1Gtpg5b3J7VGZfx4D5s0fAXiWMd9PZiVqlJ8= Received: (qmail 121547 invoked by alias); 23 Nov 2016 19:01:30 -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 121500 invoked by uid 89); 23 Nov 2016 19:01:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1589, Fully 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; Wed, 23 Nov 2016 19:01:28 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75D104E4E6; Wed, 23 Nov 2016 19:01:27 +0000 (UTC) Received: from localhost.localdomain (vpn1-5-172.ams2.redhat.com [10.36.5.172]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uANJ1QEF007842; Wed, 23 Nov 2016 14:01:26 -0500 Subject: Re: [0/3] Fix PR78120, in ifcvt/rtlanal/i386. To: GCC Patches , Uros Bizjak References: From: Bernd Schmidt Message-ID: <90a82189-d776-c568-0989-dd33b121337a@redhat.com> Date: Wed, 23 Nov 2016 20:01:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes On 11/23/2016 07:57 PM, Bernd Schmidt wrote: > 2. The i386 backend mishandles SET rtxs. If you have a fairly plain > single-insn SET, you tend to get COSTS_N_INSNS (2) out of set_rtx_cost, > because rtx_costs has a default of COSTS_N_INSNS (1) for a SET, and you > get the cost of the src in addition to that. Bernd PR rtl-optimization/78120 * config/i386/i386.c (ix86_rtx_costs): Fully handle SETs. Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c (revision 242038) +++ gcc/config/i386/i386.c (working copy) @@ -39925,6 +39925,7 @@ ix86_rtx_costs (rtx x, machine_mode mode enum rtx_code code = GET_CODE (x); enum rtx_code outer_code = (enum rtx_code) outer_code_i; const struct processor_costs *cost = speed ? ix86_cost : &ix86_size_cost; + int src_cost; switch (code) { @@ -39935,7 +39936,23 @@ ix86_rtx_costs (rtx x, machine_mode mode *total = ix86_set_reg_reg_cost (GET_MODE (SET_DEST (x))); return true; } - return false; + + if (register_operand (SET_SRC (x), VOIDmode)) + /* Avoid potentially incorrect high cost from rtx_costs + for non-tieable SUBREGs. */ + src_cost = 0; + else + { + src_cost = rtx_cost (SET_SRC (x), mode, SET, 1, speed); + + if (CONSTANT_P (SET_SRC (x))) + /* Constant costs assume a base value of COSTS_N_INSNS (1) and add + a small value, possibly zero for cheap constants. */ + src_cost += COSTS_N_INSNS (1); + } + + *total = src_cost + rtx_cost (SET_DEST (x), mode, SET, 0, speed); + return true; case CONST_INT: case CONST: