From patchwork Fri Mar 4 14:27:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 592061 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 8280C140291 for ; Sat, 5 Mar 2016 01:28:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=AWQD2T3X; 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:from :date:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; q=dns; s=default; b=LAG9ks6SDNAlKW+z 0zF0+9l2yf6+PsoIbKjDKLoVKKeUWs6ViP/tsacRjkIOmJzjl4Bkfneig0NFzSNo 68SF3MJdFzVpulwvxFy/m2S2bzGStP50eVQ24qMXdBy629a6Ged8Bh2KNZp5vP3q 5+HjOk8VN4KQwocLm6AsvQD17C4= 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 :date:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; s=default; bh=JZMwk/ui++ZShL76nVqjW0 1zO1I=; b=AWQD2T3Xll2tFdppMMkCypp87h8fSFDtvdFtxZqM2/sa5OBIouRdys kEx2IMve2TEaowt/7eI7UeuUpTMazInnfQPrOH0azAcIR2Y03C3lJmomHBFQdXkd WB3Nk781++Wp8zjdxaQahuaB9k4PWjVRPmgEMtFi9GDoi24Rc6DnI= Received: (qmail 74909 invoked by alias); 4 Mar 2016 14:27:52 -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 74899 invoked by uid 89); 4 Mar 2016 14:27:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=H*MI:sk:1457098, H*c:HHHH, our X-HELO: mail-qg0-f49.google.com Received: from mail-qg0-f49.google.com (HELO mail-qg0-f49.google.com) (209.85.192.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 04 Mar 2016 14:27:50 +0000 Received: by mail-qg0-f49.google.com with SMTP id w104so44311091qge.1 for ; Fri, 04 Mar 2016 06:27:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=wSQxMs/ijJabfJE0cj0/tZffzqHFbJdPdLSOTjVLfcM=; b=K0GLs0Osl/YwP49lcWkyF1s2XgOeqdWMgkBJcpyuIrZcI79LZEup+wqpJ3HMD3yu9I RjT9PAVi+4scgra4PzUosubeJo8Cds9GbWoRBbvxTeuZXkuCGd7fDW+TNfzX6TejsmJD QEK1L86UYBZEjedAfVpOsuWI/yX51L8PLyGliFYoVw+dgZhiFL6EuCVkeLHp5Fjm9hch UjiehnFOZVxgT9tV18wkc8PfR2dqfzgkjb6ZnV+um/0efsHUC/FI7mrfL7oh6JUlpuA8 Rk25Qj1BjqdsufVbRab9yAcK2dwrNs9skG4Obar3onL9JBIDCfDSkOumLc6Kj4NRGnP4 gj8Q== X-Gm-Message-State: AD7BkJKeMIww+9Ba2qw+P4Cd/v55VszD4ZGNg9o2YzFuJ7oSqskZebXbM/ZYc0PT+VDhBA== X-Received: by 10.140.240.3 with SMTP id l3mr10253592qhc.93.1457101668218; Fri, 04 Mar 2016 06:27:48 -0800 (PST) Received: from [192.168.1.130] (ool-4353abbc.dyn.optonline.net. [67.83.171.188]) by smtp.gmail.com with ESMTPSA id 191sm1682023qhq.17.2016.03.04.06.27.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Mar 2016 06:27:47 -0800 (PST) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Fri, 4 Mar 2016 09:27:46 -0500 (EST) To: David Malcolm cc: Patrick Palka , =?ISO-8859-15?Q?Jesper_Broge_J=F8rgensen?= , Bernd Schmidt , Richard Biener , Jeff Law , GCC Patches Subject: Re: [PING] genattrab.c generate switch In-Reply-To: <1457098838.1637.30.camel@redhat.com> Message-ID: References: <569CF21F.5020603@gmail.com> <569D3372.9050607@redhat.com> <569E2248.9040605@gmail.com> <56C5B77A.3050900@redhat.com> <56D8ACAF.4060705@gmail.com> <1457098838.1637.30.camel@redhat.com> User-Agent: Alpine 2.20.9 (DEB 106 2015-09-22) MIME-Version: 1.0 On Fri, 4 Mar 2016, David Malcolm wrote: > On Thu, 2016-03-03 at 17:36 -0500, Patrick Palka wrote: >> On Thu, Mar 3, 2016 at 4:29 PM, Jesper Broge Jørgensen >> wrote: >>> >>> On 18/02/16 13:22, Bernd Schmidt wrote: >>>> >>>> On 01/19/2016 12:47 PM, Jesper Broge Jørgensen wrote: >>>>> >>>>> Here is the reformatted patch: >>>> >>>> >>>> This will probably have to wait until stage1. >>>> >>>>> + const int code = GET_CODE (op2); >>>>> + if (code != IOR) >>>>> + { >>>>> + if (code == EQ_ATTR) >>>> >>>> >>>> All the formatting still looks completely mangled. This was >>>> probably done >>>> by your mailer. Please try attaching the diff as text/plain. >>>> >>>> >>>> Bernd >>>> >>> Hi i send the patch back as an attatchment as requested about two >>> weeks ago >>> (https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01256.html) but i >>> have not >>> received any response. >>> >>> If it has to wait for stage 1 are there anything else i can do for >>> the patch >>> untill then? >> >> I still suggest to try making write_test_expr() avoid emitting >> redundant parentheses for chains of || or &&, which would fix the >> original issue all the same. Previously you claimed that such a >> change would not be simpler than your current patch, but I gave it a >> quick try and ended up with a much smaller patch: >> >> gcc/genattrtab.c | 26 +++++++++++++++++++------- >> 1 file changed, 19 insertions(+), 7 deletions(-) > > Patrick, did you forget to attach the patch? I see the diffstat, but > no patch. > Here it is: -- >8 -- Subject: [PATCH] Reduce nesting of parentheses in conditionals generated by genattrtab gcc/ChangeLog: * genattrtab.c (write_test_expr): New parameter EMIT_PARENS which defaults to true. Emit an outer pair of parentheses only if EMIT_PARENS. When continuing a chain of && or ||, don't emit parentheses for the right-hand operand. --- gcc/genattrtab.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c index b64d8b9..e2ccf1f 100644 --- a/gcc/genattrtab.c +++ b/gcc/genattrtab.c @@ -3432,16 +3432,16 @@ find_attrs_to_cache (rtx exp, bool create) #define FLG_OUTSIDE_AND 8 static unsigned int -write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags) +write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags, + bool emit_parens = true) { int comparison_operator = 0; RTX_CODE code; struct attr_desc *attr; - /* In order not to worry about operator precedence, surround our part of - the expression with parentheses. */ + if (emit_parens) + fprintf (outf, "("); - fprintf (outf, "("); code = GET_CODE (exp); switch (code) { @@ -3575,8 +3575,18 @@ write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags) || GET_CODE (XEXP (exp, 1)) == EQ_ATTR || (GET_CODE (XEXP (exp, 1)) == NOT && GET_CODE (XEXP (XEXP (exp, 1), 0)) == EQ_ATTR))) - attrs_cached - = write_test_expr (outf, XEXP (exp, 1), attrs_cached, flags); + { + bool need_parens = true; + + /* No need to emit parentheses around the right-hand operand if we are + continuing a chain of && or ||. */ + if (GET_CODE (XEXP (exp, 1)) == code) + need_parens = false; + + attrs_cached + = write_test_expr (outf, XEXP (exp, 1), attrs_cached, flags, + need_parens); + } else write_test_expr (outf, XEXP (exp, 1), attrs_cached, flags | comparison_operator); @@ -3794,7 +3804,9 @@ write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags) GET_RTX_NAME (code)); } - fprintf (outf, ")"); + if (emit_parens) + fprintf (outf, ")"); + return attrs_cached; }