From patchwork Wed Nov 28 20:09:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1004822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-491150-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="UdHSi1Dd"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 434sDz5ngGz9s3C for ; Thu, 29 Nov 2018 07:09:22 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=oFAj4pfLsL07EPufSGAoSmU+/f87Z28hWhs+m//V4jexAII1Vg2ZY F+Iu9YI3eDUdHqQr3GvnBHopD2kDHiVqM8S7hWbjgvINi2vAVQ/a2hwWMIydQ3fr kgc/2Hb7+0D7xsJJjQwUFSnutufmPW8RWsyP/clWpxs0cW4T2RSwMY= 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:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=bKVsEphnxuNyMgg6oVrvC45xCaE=; b=UdHSi1DdadMgOolCVHBE fBGbvcY/JcnrTaTxJAvWYShufsobusE/hD8FkdeTNVxldzAZSUNg5SBAFKxNJgfq NGZtDl2F5I8ogyVUQTr6Z4Z5zk7SVznSzxUIXmh4Is6Z2ewDCoTtxIVVAWgy0SX5 BsuL1/77Q+fmRBZuk8QmnFs= Received: (qmail 16857 invoked by alias); 28 Nov 2018 20:09:15 -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 16844 invoked by uid 89); 28 Nov 2018 20:09:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?iso-8859-1?q?No=2C_score=3D-10=2E6_required=3D5=2E?= =?iso-8859-1?q?0_tests=BAYES_00=2CGIT_PATCH_2=2CGIT_PATCH_3=2CKAM_?= =?iso-8859-1?q?ASCII_DIVIDERS=2CKAM_NUMSUBJECT=2CKAM_SHORT=2CSPF_H?= =?iso-8859-1?q?ELO_PASS_autolearn=3Dham_version=3D3=2E3=2E2_spammy?= =?iso-8859-1?q?=3DUD=3A=C2=2C_266435=2C_accounted=2C_H*u=3A52=2E6?= =?iso-8859-1?q?=2E0?= 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, 28 Nov 2018 20:09:12 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FC8A811DA for ; Wed, 28 Nov 2018 20:09:11 +0000 (UTC) Received: from [10.10.125.194] (ovpn-125-194.rdu2.redhat.com [10.10.125.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id E90A668719 for ; Wed, 28 Nov 2018 20:09:10 +0000 (UTC) From: Vladimir Makarov Subject: patch to fix PR88207 To: "gcc-patches@gcc.gnu.org" Message-ID: <64f0bdd4-f8e6-d656-95fd-bf6660fa1cdd@redhat.com> Date: Wed, 28 Nov 2018 15:09:09 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 X-IsSubscribed: yes The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88207   The patch was tested and bootstrapped on x86/x86-64.   Committed as rev. 266582.   The patch creates one new regression on pr34256.c.  But I think gcc with the patch generates the right code.  I'll send a patch modifying the test for discussion and/or approval later today. Index: ChangeLog =================================================================== --- ChangeLog (revision 266581) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2018-11-28 Vladimir Makarov + + PR target/88207 + * ira-costs.c (scan_one_insn): Process subregs when updating costs + for pseudos and allocnos from insn. + 2018-11-28 David Edelsohn * config/rs6000/aix72.h: Update to match aix71.h changes. Index: ira-costs.c =================================================================== --- ira-costs.c (revision 266435) +++ ira-costs.c (working copy) @@ -1535,36 +1535,40 @@ scan_one_insn (rtx_insn *insn) /* Now add the cost for each operand to the total costs for its allocno. */ for (i = 0; i < recog_data.n_operands; i++) - if (REG_P (recog_data.operand[i]) - && REGNO (recog_data.operand[i]) >= FIRST_PSEUDO_REGISTER) - { - int regno = REGNO (recog_data.operand[i]); - struct costs *p = COSTS (costs, COST_INDEX (regno)); - struct costs *q = op_costs[i]; - int *p_costs = p->cost, *q_costs = q->cost; - cost_classes_t cost_classes_ptr = regno_cost_classes[regno]; - int add_cost; - - /* If the already accounted for the memory "cost" above, don't - do so again. */ - if (!counted_mem) - { - add_cost = q->mem_cost; - if (add_cost > 0 && INT_MAX - add_cost < p->mem_cost) - p->mem_cost = INT_MAX; - else - p->mem_cost += add_cost; - } - for (k = cost_classes_ptr->num - 1; k >= 0; k--) - { - add_cost = q_costs[k]; - if (add_cost > 0 && INT_MAX - add_cost < p_costs[k]) - p_costs[k] = INT_MAX; - else - p_costs[k] += add_cost; - } - } - + { + rtx op = recog_data.operand[i]; + + if (GET_CODE (op) == SUBREG) + op = SUBREG_REG (op); + if (REG_P (op) && REGNO (op) >= FIRST_PSEUDO_REGISTER) + { + int regno = REGNO (op); + struct costs *p = COSTS (costs, COST_INDEX (regno)); + struct costs *q = op_costs[i]; + int *p_costs = p->cost, *q_costs = q->cost; + cost_classes_t cost_classes_ptr = regno_cost_classes[regno]; + int add_cost; + + /* If the already accounted for the memory "cost" above, don't + do so again. */ + if (!counted_mem) + { + add_cost = q->mem_cost; + if (add_cost > 0 && INT_MAX - add_cost < p->mem_cost) + p->mem_cost = INT_MAX; + else + p->mem_cost += add_cost; + } + for (k = cost_classes_ptr->num - 1; k >= 0; k--) + { + add_cost = q_costs[k]; + if (add_cost > 0 && INT_MAX - add_cost < p_costs[k]) + p_costs[k] = INT_MAX; + else + p_costs[k] += add_cost; + } + } + } return insn; }