From patchwork Fri Jan 13 18:19:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Preudhomme X-Patchwork-Id: 91483 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp320233qgi; Fri, 13 Jan 2017 10:20:09 -0800 (PST) X-Received: by 10.99.164.18 with SMTP id c18mr2253050pgf.40.1484331609469; Fri, 13 Jan 2017 10:20:09 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o5si13409179plh.162.2017.01.13.10.20.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jan 2017 10:20:09 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-446130-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-446130-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-446130-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=DliQVhM02QrYHOBjI 9p7+saaMGqmegV2BWhOI4GOuzjK5BphdOtUyS0eUCdAKns+NYI0Cnd9HBs9qSqeY CThJo+oVQH8WLmEinhiYv4GmUW7yGJzXz3/8OTNDscfyo+ZO3/s4JolaW8IpayQ5 uz3BP0AaJDourjhGcRU8nXdVxU= 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=hbQbO856jAu4dwyIh3HgV0H q22c=; b=rL9NSzaMWD8Fw8SkX4fjhebw9mxkZOaejyTdnffyFvFSbKMQJHpYpmt KkapPpj/7NGc26n3cRoNDCg3A+bs8aJPDSL688nDGGXCeXNcw6Xsli8rkViuWMl+ LtCNS0YgAee2ST+b7KiT6U8OnQIROohUSh67nq7mIzu+fGLgFS20= Received: (qmail 106093 invoked by alias); 13 Jan 2017 18:19:21 -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 106051 invoked by uid 89); 13 Jan 2017 18:19:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=fn3, fn4, 2016-12-07, 20161207 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, 13 Jan 2017 18:19:10 +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 AA407C14; Fri, 13 Jan 2017 10:19:09 -0800 (PST) Received: from [10.2.206.52] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E9C503F242; Fri, 13 Jan 2017 10:19:08 -0800 (PST) Subject: Re: [PATCH, GCC/LRA, gcc-5/6-branch] Fix PR78617: Fix conflict detection in rematerialization To: "gcc-patches@gcc.gnu.org" , Vladimir Makarov , Richard Biener , Jakub Jelinek References: <0045efc7-b684-6452-542d-07dab43f92ac@foss.arm.com> From: Thomas Preudhomme Message-ID: <913bab85-c591-22a6-37b3-31e1f57ae77b@foss.arm.com> Date: Fri, 13 Jan 2017 18:19:07 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <0045efc7-b684-6452-542d-07dab43f92ac@foss.arm.com> X-IsSubscribed: yes Ping? I'm not sure if an ok from Valdimir is enough or if I also need RM approval. Best regards, Thomas On 09/01/17 09:51, Thomas Preudhomme wrote: > Hi, > > Is it ok to backport the fix for PR78617 (incorrect conflict detection in > rematerialization) to GCC 5 and GCC 6? The patch applies cleanly and the > testsuite showed no regression when performed with the following configurations: > > - an arm-none-eabi GCC cross-compiler targeting Cortex-M0 and Cortex-M3 > - a bootstrapped arm-linux-gnueabihf GCC native compiler > - a bootstrapped x86_64-linux-gnu GCC native compiler > > ChangeLog entry is as follows: > > *** gcc/ChangeLog *** > > 2017-01-03 Thomas Preud'homme > > Backport from mainline > 2016-12-07 Thomas Preud'homme > > PR rtl-optimization/78617 > * lra-remat.c (do_remat): Initialize live_hard_regs from live in > registers, also setting hard registers mapped to pseudo registers. > > > *** gcc/testsuite/ChangeLog *** > > > 2017-01-03 Thomas Preud'homme > > Backport from mainline > 2016-12-07 Thomas Preud'homme > > PR rtl-optimization/78617 > * gcc.c-torture/execute/pr78617.c: New test. > > > Best regards, > > Thomas diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c index 187ee3e7752d1ebe15ba8e8014620c0a94e11424..79504d4eb1a052d906a69178d847e6e618b468ec 100644 --- a/gcc/lra-remat.c +++ b/gcc/lra-remat.c @@ -1116,6 +1116,7 @@ update_scratch_ops (rtx_insn *remat_insn) static bool do_remat (void) { + unsigned regno; rtx_insn *insn; basic_block bb; bitmap_head avail_cands; @@ -1123,12 +1124,21 @@ do_remat (void) bool changed_p = false; /* Living hard regs and hard registers of living pseudos. */ HARD_REG_SET live_hard_regs; + bitmap_iterator bi; bitmap_initialize (&avail_cands, ®_obstack); bitmap_initialize (&active_cands, ®_obstack); FOR_EACH_BB_FN (bb, cfun) { - REG_SET_TO_HARD_REG_SET (live_hard_regs, df_get_live_out (bb)); + CLEAR_HARD_REG_SET (live_hard_regs); + EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb), 0, regno, bi) + { + int hard_regno = regno < FIRST_PSEUDO_REGISTER + ? regno + : reg_renumber[regno]; + if (hard_regno >= 0) + SET_HARD_REG_BIT (live_hard_regs, hard_regno); + } bitmap_and (&avail_cands, &get_remat_bb_data (bb)->avin_cands, &get_remat_bb_data (bb)->livein_cands); /* Activating insns are always in the same block as their corresponding diff --git a/gcc/testsuite/gcc.c-torture/execute/pr78617.c b/gcc/testsuite/gcc.c-torture/execute/pr78617.c new file mode 100644 index 0000000000000000000000000000000000000000..89c4f6dea8cb507b963f91debb94cbe16eb1db90 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr78617.c @@ -0,0 +1,25 @@ +int a = 0; +int d = 1; +int f = 1; + +int fn1() { + return a || 1 >> a; +} + +int fn2(int p1, int p2) { + return p2 >= 2 ? p1 : p1 >> 1; +} + +int fn3(int p1) { + return d ^ p1; +} + +int fn4(int p1, int p2) { + return fn3(!d > fn2((f = fn1() - 1000) || p2, p1)); +} + +int main() { + if (fn4(0, 0) != 1) + __builtin_abort (); + return 0; +}