From patchwork Fri Nov 27 09:44:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 57356 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1024097lbb; Fri, 27 Nov 2015 01:45:21 -0800 (PST) X-Received: by 10.98.14.155 with SMTP id 27mr46771782pfo.92.1448617520972; Fri, 27 Nov 2015 01:45:20 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id rx6si15402293pac.24.2015.11.27.01.45.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Nov 2015 01:45:20 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-415611-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-415611-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-415611-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=N+oJIJcOR5CAeHX1u x7Zdv4GMsRcJ0WH6ddaIWgRIyzY77lZ1+7m4MJrqCaoofZM8JlAB6QePTFl9YCr7 65JcST4Asj5IziVgjAFrPhKNx4Ucp9V1VHwxgvPi4x6cP5FsTL9tkEc4lJqje++h jBJssO3V0Th00W+v0lfiOYH88k= 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=DKM1O+1fkQf3Hi6+7HthJSq 6xaM=; b=xRzRtkdlp5avBN4WIj28bjclNSinFHOHtHVHFNcXXZVjVRIM4srMDbG LaxZH8Jw0e6o1raMAqU6ootbzXTwIxyeWOXLtbNIR1tcWcwsS0PYTTZpXmHtmb5M 9ynx+74yQmgVTLyCoLg5c2wAfa70b3Wn+bzF3JpHVKazolAsszbw= Received: (qmail 60940 invoked by alias); 27 Nov 2015 09:45:07 -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 60921 invoked by uid 89); 27 Nov 2015 09:45:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Nov 2015 09:45:05 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-26-P_sN5__DRoisrx0kEzBNNw-1; Fri, 27 Nov 2015 09:44:59 +0000 Received: from [10.2.206.200] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Nov 2015 09:44:59 +0000 Message-ID: <5658261A.1030201@arm.com> Date: Fri, 27 Nov 2015 09:44:58 +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: Bernd Schmidt , GCC Patches Subject: Re: [PATCH][RTL-ifcvt] PR rtl-optimization/68506: Fix emitting order of insns in IF-THEN-JOIN case References: <5656E924.4030603@arm.com> <56570BDB.9070804@redhat.com> <56570EAA.1070808@arm.com> <565715D9.4070702@redhat.com> <56571895.90809@arm.com> <5657372D.4080907@arm.com> <5657382D.7020804@redhat.com> <5657394B.9030201@arm.com> In-Reply-To: <5657394B.9030201@arm.com> X-MC-Unique: P_sN5__DRoisrx0kEzBNNw-1 X-IsSubscribed: yes On 26/11/15 16:54, Kyrill Tkachov wrote: > > On 26/11/15 16:49, Bernd Schmidt wrote: >> On 11/26/2015 05:45 PM, Kyrill Tkachov wrote: >>> that doesn't help, punt. */ >>> >>> - modified_in_a = emit_a != NULL_RTX && modified_in_p (orig_b, emit_a); >>> if (tmp_b && then_bb) >>> { >> These bits I thought would be part of a followup patch (which would also guard against single_set problems), and as I mentioned I'd rather have a checking assert. > Yes, you're right. I have the checking_assert statement in the followup that I've been testing. > I'll move the deletion of these two statements there as well to minimise the changes to this patch. > > I'll move these bits to that patch, re-build cc1 and commit. > Here it is. I'm committing this to trunk. Thanks, Kyrill 2015-11-26 Kyrylo Tkachov PR rtl-optimization/68506 * ifcvt.c (noce_try_cmove_arith): Try emitting the else basic block first if emit_a exists or then_bb modifies 'b'. Reindent if-else blocks. 2015-11-26 Kyrylo Tkachov PR rtl-optimization/68506 * gcc.c-torture/execute/pr68506.c: New test. > Thanks for your guidance, > Kyrill > >> So take these deletions out and leave them for the followup, and the patch is ok everywhere. No need for a full retest given that practically the same patch has been tested already, just make sure you can build cc1. >> >> >> Bernd >> > commit ba7633ec30e8e25d7dc1975893bf56eadf223404 Author: Kyrylo Tkachov Date: Tue Nov 24 11:49:30 2015 +0000 PR rtl-optimization/68506: Fix emitting order of insns in IF-THEN-JOIN case diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index af7a3b9..3ce9fe6 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -2220,40 +2220,38 @@ noce_try_cmove_arith (struct noce_if_info *if_info) } } - if (emit_a && modified_in_a) - { - modified_in_b = emit_b != NULL_RTX && modified_in_p (orig_a, emit_b); - if (tmp_b && else_bb) - { - FOR_BB_INSNS (else_bb, tmp_insn) - /* Don't check inside insn_b. We will have changed it to emit_b - with a destination that doesn't conflict. */ - if (!(insn_b && tmp_insn == insn_b) - && modified_in_p (orig_a, tmp_insn)) - { - modified_in_b = true; - break; - } - - } - if (modified_in_b) - goto end_seq_and_fail; - - if (!noce_emit_bb (emit_b, else_bb, b_simple)) - goto end_seq_and_fail; + if (emit_a || modified_in_a) + { + modified_in_b = emit_b != NULL_RTX && modified_in_p (orig_a, emit_b); + if (tmp_b && else_bb) + { + FOR_BB_INSNS (else_bb, tmp_insn) + /* Don't check inside insn_b. We will have changed it to emit_b + with a destination that doesn't conflict. */ + if (!(insn_b && tmp_insn == insn_b) + && modified_in_p (orig_a, tmp_insn)) + { + modified_in_b = true; + break; + } + } + if (modified_in_b) + goto end_seq_and_fail; - if (!noce_emit_bb (emit_a, then_bb, a_simple)) - goto end_seq_and_fail; - } - else - { - if (!noce_emit_bb (emit_a, then_bb, a_simple)) - goto end_seq_and_fail; + if (!noce_emit_bb (emit_b, else_bb, b_simple)) + goto end_seq_and_fail; - if (!noce_emit_bb (emit_b, else_bb, b_simple)) - goto end_seq_and_fail; + if (!noce_emit_bb (emit_a, then_bb, a_simple)) + goto end_seq_and_fail; + } + else + { + if (!noce_emit_bb (emit_a, then_bb, a_simple)) + goto end_seq_and_fail; - } + if (!noce_emit_bb (emit_b, else_bb, b_simple)) + goto end_seq_and_fail; + } target = noce_emit_cmove (if_info, x, code, XEXP (if_info->cond, 0), XEXP (if_info->cond, 1), a, b); diff --git a/gcc/testsuite/gcc.c-torture/execute/pr68506.c b/gcc/testsuite/gcc.c-torture/execute/pr68506.c new file mode 100644 index 0000000..15984ed --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr68506.c @@ -0,0 +1,63 @@ +/* { dg-options "-fno-builtin-abort" } */ + +int a, b, m, n, o, p, s, u, i; +char c, q, y; +short d; +unsigned char e; +static int f, h; +static short g, r, v; +unsigned t; + +extern void abort (); + +int +fn1 (int p1) +{ + return a ? p1 : p1 + a; +} + +unsigned char +fn2 (unsigned char p1, int p2) +{ + return p2 >= 2 ? p1 : p1 >> p2; +} + +static short +fn3 () +{ + int w, x = 0; + for (; p < 31; p++) + { + s = fn1 (c | ((1 && c) == c)); + t = fn2 (s, x); + c = (unsigned) c > -(unsigned) ((o = (m = d = t) == p) <= 4UL) && n; + v = -c; + y = 1; + for (; y; y++) + e = v == 1; + d = 0; + for (; h != 2;) + { + for (;;) + { + if (!m) + abort (); + r = 7 - f; + x = e = i | r; + q = u * g; + w = b == q; + if (w) + break; + } + break; + } + } + return x; +} + +int +main () +{ + fn3 (); + return 0; +}