From patchwork Thu Feb 2 09:31:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 722940 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3vDZWv60HXz9s7L for ; Thu, 2 Feb 2017 20:31:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bIm2Y0VX"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=vMlcCwXc1ipAyQNzqMrRIbHal9uC9I X6Dw6ya8rZbQTXR0vi3XesAdC8ImseOpA0YxP/tptFHkfrpPiC5jiDDEOzQsCX0a ZUjFQUiXhiv8b4KPZDaMpwcuKEYzegsSOsojE29LXsab1Z1niF8r1R5Eo5PzJVv2 LX9HqY805nmYs= 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:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=jpVutEAD156hC8odfz08FQZ/iaI=; b=bIm2 Y0VXaaZvr/Ho+8Ubx3xX2ZmJURQA69QlCfADHJG7+1Ds4JY9k/MezyiHsXjhdZpX em/j5LBDR8bBRUqy5Gve5iQqICY9Mwa0UqUNcc1GX7J7+s3MSUQoTpejJ8Xt6L+0 cfH9SKyGoMNymMu6rqg2vgcMh8+043D93Fa1RYQ= Received: (qmail 45222 invoked by alias); 2 Feb 2017 09:31:48 -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 45205 invoked by uid 89); 2 Feb 2017 09:31:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=cures, PR79286, pr79286, xexp X-HELO: mail-pg0-f44.google.com Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Feb 2017 09:31:46 +0000 Received: by mail-pg0-f44.google.com with SMTP id 3so4400579pgj.3 for ; Thu, 02 Feb 2017 01:31:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Tf6qh2upsw3ALBGv7Eyp7OenRQHkjadN72+XjRSylcY=; b=L+g1z9bI0u+oGKhYMq45viOF+hTRLwGNqokF8bFAk2vkjhzmuYa2l5YvAfn1ChDjuX Zt1R2XRRE4zKt5mZ4FMQnzxbJjpFPHXKI7ZOnxY8m+6dzvyxmtx/R+CiYFfdSVoSqOz/ vEkTYAuh1okEPwOMjYbg6Oj2M1z6PNXq3b+XYAVENUdcM7ziia1qFmWOrVLW3H+EGuox wOcBhVcZof2wO/izGdNtaDZ0wY7Ydd9Pr7dWw2/5eQ8kRyvAD1o+DMvDVP4g/qnZAUsq Um2ICR+iKcVQEuhwJ4HrpQ5SL2muzzcchsa7zOJ1qCLFZclg9DzaJFDg80UzcBCQSknc mB1g== X-Gm-Message-State: AIkVDXLJtJojPzD0oZZQp6ZraAn0t2VvuBsYDlHjNwz2DvZggbDZn1B8s30mHnb9bpS0cA== X-Received: by 10.84.248.70 with SMTP id e6mr11107129pln.179.1486027904100; Thu, 02 Feb 2017 01:31:44 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-160-71-80.tyqh2.lon.bigpond.net.au. [58.160.71.80]) by smtp.gmail.com with ESMTPSA id 19sm56512908pft.46.2017.02.02.01.31.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Feb 2017 01:31:43 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id E1615C318C; Thu, 2 Feb 2017 20:01:38 +1030 (ACDT) Date: Thu, 2 Feb 2017 20:01:38 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Subject: Re: PR79286, ira combine_and_move_insns in loops Message-ID: <20170202093138.GF3731@bubble.grove.modra.org> References: <20170201134830.GA3731@bubble.grove.modra.org> <20170201213722.GB3731@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170201213722.GB3731@bubble.grove.modra.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Revised patch that cures the lra related -m32 -Os regression too. The code that I'm patching here is changing a REG_EQUAL note to REG_EQUIV, ie. asserting that the value of the reg is always the value set by the current instruction. Which is not always true when the insn is in a loop and the use of the reg happens before the def. Of course that implies the value of the reg is initially undefined, so it's not unreasonable to make the initial reg value the same. Except when the code setting the initial value may trap, as it does in the testcase. Bootstrap and regression test on x86_64-linux in progress. OK assuming no regressions? I also took a look at gcc/*.o to see whether there were any code quality regressions. No differences found except the expected change in ira.o. PR rtl-optimization/79286 * ira.c (update_equiv_regs): Do not create an equivalence for mems that may trap. testsuite/ * gcc.c-torture/execute/pr79286.c: New. diff --git a/gcc/ira.c b/gcc/ira.c index 96b4b62..8e79929 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -3500,7 +3500,9 @@ update_equiv_regs (void) /* If this register is known to be equal to a constant, record that it is always equivalent to the constant. */ if (DF_REG_DEF_COUNT (regno) == 1 - && note && ! rtx_varies_p (XEXP (note, 0), 0)) + && note + && !rtx_varies_p (XEXP (note, 0), 0) + && !may_trap_p (XEXP (note, 0))) { rtx note_value = XEXP (note, 0); remove_note (insn, note); diff --git a/gcc/testsuite/gcc.c-torture/execute/pr79286.c b/gcc/testsuite/gcc.c-torture/execute/pr79286.c new file mode 100644 index 0000000..e6d0e93 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr79286.c @@ -0,0 +1,15 @@ +int a = 0, c = 0; +static int d[][8] = {}; + +int main () +{ + int e; + for (int b = 0; b < 4; b++) + { + __builtin_printf ("%d\n", b, e); + while (a && c++) + e = d[300000000000000000][0]; + } + + return 0; +}