From patchwork Tue Nov 24 13:22:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 57235 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2090341lbb; Tue, 24 Nov 2015 05:34:07 -0800 (PST) X-Received: by 10.98.80.135 with SMTP id g7mr23027122pfj.83.1448372047037; Tue, 24 Nov 2015 05:34:07 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id qh12si26554947pab.145.2015.11.24.05.34.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Nov 2015 05:34:07 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-415190-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; spf=pass (google.com: domain of gcc-patches-return-415190-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-415190-patch=linaro.org@gcc.gnu.org; dkim=pass header.i=@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 :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=IL+7WdroIe6t3Beg3 QujubHkXThnAVfNH3YJHTJfEoq4LFvfhhTvrMf5g6QAQ/Q0ZPecrEkYXy4SGEJaI J5C5SOlJ4USp8lerNamZyBQNAjY5xVKaJ1V4wYZduXkoY3Ym6aqiJdeNpQv949JA pxngV9CzkMp5GF8jyd6rw4gDBk= 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 :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=zzj67vP6o2rMIkN+lkqJbZQ Ds6w=; b=XmDHhEMB8d4/+ta3kL+pyUB/2tBil4R8w+AAHsjLia5WENPOIx4UAJp o7FPI/CIaMQcBmuFW875oJoW3U1SeEa0qWhmcXS58VRGf2JtKOtkDcpsbA6DO8v0 R6udkdJ+Cajuct/60RWI6CrnHVtyxY1mDH99cd/KgMA3h8pyTYmg= Received: (qmail 76648 invoked by alias); 24 Nov 2015 13:33:35 -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 76562 invoked by uid 89); 24 Nov 2015 13:33:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: cam-smtp0.cambridge.arm.com Received: from fw-tnat.cambridge.arm.com (HELO cam-smtp0.cambridge.arm.com) (217.140.96.140) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 24 Nov 2015 13:33:30 +0000 Received: from geoffrey.Emea.Arm.com (geoffrey.emea.arm.com [10.1.255.46]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id tAODXM3A006162; Tue, 24 Nov 2015 13:33:26 GMT Received: from cam-owa1.Emea.Arm.com ([10.1.255.62]) by geoffrey.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 24 Nov 2015 13:33:22 +0000 Received: from [10.2.206.200] ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 24 Nov 2015 13:22:48 +0000 Message-ID: <565464A8.4000400@arm.com> Date: Tue, 24 Nov 2015 13:22:48 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Segher Boessenkool , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] combine: Handle aborts in is_parallel_of_n_reg_sets (PR68381) References: <579c3fee8ef39fe70575bd5e0a38ee866faf564a.1448345542.git.segher@kernel.crashing.org> In-Reply-To: <579c3fee8ef39fe70575bd5e0a38ee866faf564a.1448345542.git.segher@kernel.crashing.org> X-IsSubscribed: yes On 24/11/15 06:37, Segher Boessenkool wrote: > Some users of is_parallel_of_n_reg_sets disregard the clobbers in a > parallel after it has returned "yes, this is a parallel of N sets and > maybe some clobbers". But combine uses a clobber of const0_rtx to > indicate substitution failure, so this leads to disaster. > > Fix this by checking for such special clobbers in is_parallel_of_n_reg_sets. > > Tested on powerpc64-linux. Also tested with Kyrill's testcase, manually > inspected the generated asm and the combine dump file (with some extra > instrumentation). This testcase needs -O1 btw. > > The "performance problem" in the PR (same testcase, but with -O3) is > a missed jump optimization: a pseudo is set (to 0) in one BB (and > nowhere else), and then tested against 0 in another BB. Nothing after > combine seems to handle this. > > Applying this patch to trunk. Kyrill, could you handle the testcase? > Together with whatever you decide should be done for the -O3 problem. > Thank you for tracking down this nastiness! Sure, here's the testcase with the "-O" in the dg-options I had left out. Applying to trunk. For the performance issue I'll investigate a bit further. Thanks, Kyrill 2015-11-24 Kyrylo Tkachov PR rtl-optimization/68381 * gcc.c-torture/execute/pr68381.c: New test. > > Segher > > > 2015-11-24 Segher Boessenkool > > PR rtl-optimization/68381 > * combine.c (is_parallel_of_n_reg_sets): Return false if the pattern > is poisoned. > > --- > gcc/combine.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gcc/combine.c b/gcc/combine.c > index 2a66fd5..4958d3b 100644 > --- a/gcc/combine.c > +++ b/gcc/combine.c > @@ -2512,7 +2512,8 @@ is_parallel_of_n_reg_sets (rtx pat, int n) > || !REG_P (SET_DEST (XVECEXP (pat, 0, i)))) > return false; > for ( ; i < len; i++) > - if (GET_CODE (XVECEXP (pat, 0, i)) != CLOBBER) > + if (GET_CODE (XVECEXP (pat, 0, i)) != CLOBBER > + || XEXP (XVECEXP (pat, 0, i), 0) == const0_rtx) > return false; > > return true; commit e5ab9ee234cb7f4b25e5aa56e64cf3a8a0e56f58 Author: Kyrylo Tkachov Date: Tue Nov 17 15:33:58 2015 +0000 [combine] PR rtl-optimization/68381: Only restrict pure simplification in mult-extend subst case, allow other substitutions diff --git a/gcc/testsuite/gcc.c-torture/execute/pr68381.c b/gcc/testsuite/gcc.c-torture/execute/pr68381.c new file mode 100644 index 0000000..cb6abcb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr68381.c @@ -0,0 +1,22 @@ +/* { dg-options "-O -fexpensive-optimizations -fno-tree-bit-ccp" } */ + +__attribute__ ((noinline, noclone)) +int +foo (unsigned short x, unsigned short y) +{ + int r; + if (__builtin_mul_overflow (x, y, &r)) + __builtin_abort (); + return r; +} + +int +main (void) +{ + int x = 1; + int y = 2; + if (foo (x, y) != x * y) + __builtin_abort (); + return 0; +} +