From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28011 invoked by alias); 7 Jan 2019 12:10:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27973 invoked by uid 89); 7 Jan 2019 12:10:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: foss.arm.com Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Jan 2019 12:10:42 +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 5F0CC1596; Mon, 7 Jan 2019 04:10:40 -0800 (PST) Received: from localhost (unknown [10.32.98.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B209E3F5AF; Mon, 7 Jan 2019 04:10:39 -0800 (PST) From: Richard Sandiford To: Alan Modra Mail-Followup-To: Alan Modra ,gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] genattrtab bit-rot, and if_then_else in values References: <20190103092154.GZ30978@bubble.grove.modra.org> <87a7khsyjz.fsf@arm.com> <20190103143637.GA3170@bubble.grove.modra.org> <87lg41r7nb.fsf@arm.com> <87h8epr2ao.fsf@arm.com> <20190104001952.GB3170@bubble.grove.modra.org> <87imz4pqf8.fsf@arm.com> <20190106223632.GF3170@bubble.grove.modra.org> Date: Mon, 07 Jan 2019 12:10:00 -0000 In-Reply-To: <20190106223632.GF3170@bubble.grove.modra.org> (Alan Modra's message of "Mon, 7 Jan 2019 09:06:32 +1030") Message-ID: <87imz0mzwh.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2019-01/txt/msg00291.txt.bz2 Alan Modra writes: > On Fri, Jan 04, 2019 at 12:18:03PM +0000, Richard Sandiford wrote: >> Alan Modra writes: >> > On Thu, Jan 03, 2019 at 07:03:59PM +0000, Richard Sandiford wrote: >> >> Richard Sandiford writes: >> >> > This still seems risky and isn't what the name and function comment >> > >> > OK, how about this delta from the previous patch to ameliorate the >> > maintenance risk? >> >> attr_value_alignment seems clearer, and means that we can handle >> things like: >> >> (mult (symbol_ref "...") (const_int 4)) > > OK, revised patch as follows, handling MINUS and MULT in the max/min > value functions too. > > * genattrtab.c (max_attr_value, min_attr_value, or_attr_value): > Delete "unknownp" parameter. Adjust callers. Handle > CONST_INT, PLUS, MINUS, and MULT. > (attr_value_aligned): Renamed from or_attr_value. > (min_attr_value): Return INT_MIN for unhandled rtl case.. > (min_fn): ..and translate to INT_MAX here. > (write_length_unit_log): Modify to cope without "unknown". > (write_attr_value): Handle IF_THEN_ELSE. > > diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c > index 2cd04cdb06f..b8adf704009 100644 > --- a/gcc/genattrtab.c > +++ b/gcc/genattrtab.c > @@ -266,9 +266,9 @@ static int compares_alternatives_p (rtx); > static void make_internal_attr (const char *, rtx, int); > static void insert_insn_ent (struct attr_value *, struct insn_ent *); > static void walk_attr_value (rtx); > -static int max_attr_value (rtx, int*); > -static int min_attr_value (rtx, int*); > -static int or_attr_value (rtx, int*); > +static int max_attr_value (rtx); > +static int min_attr_value (rtx); > +static unsigned int attr_value_alignment (rtx); > static rtx simplify_test_exp (rtx, int, int); > static rtx simplify_test_exp_in_temp (rtx, int, int); > static rtx copy_rtx_unchanging (rtx); > @@ -1550,15 +1550,16 @@ one_fn (rtx exp ATTRIBUTE_UNUSED) > static rtx > max_fn (rtx exp) > { > - int unknown; > - return make_numeric_value (max_attr_value (exp, &unknown)); > + return make_numeric_value (max_attr_value (exp)); > } > > static rtx > min_fn (rtx exp) > { > - int unknown; > - return make_numeric_value (min_attr_value (exp, &unknown)); > + int val = min_attr_value (exp); > + if (val < 0) > + val = INT_MAX; > + return make_numeric_value (val); > } > > static void > @@ -1568,24 +1569,21 @@ write_length_unit_log (FILE *outf) > struct attr_value *av; > struct insn_ent *ie; > unsigned int length_unit_log, length_or; > - int unknown = 0; > > if (length_attr) > { > - length_or = or_attr_value (length_attr->default_val->value, &unknown); > + length_or = attr_value_alignment (length_attr->default_val->value); > for (av = length_attr->first_value; av; av = av->next) > for (ie = av->first_insn; ie; ie = ie->next) > - length_or |= or_attr_value (av->value, &unknown); > - } > + length_or |= attr_value_alignment (av->value); > > - if (length_attr == NULL || unknown) > - length_unit_log = 0; > - else > - { > length_or = ~length_or; > for (length_unit_log = 0; length_or & 1; length_or >>= 1) > length_unit_log++; > } > + else > + length_unit_log = 0; > + > fprintf (outf, "EXPORTED_CONST int length_unit_log = %u;\n", length_unit_log); > } > > @@ -3753,11 +3751,12 @@ write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags, > return attrs_cached; > } > > -/* Given an attribute value, return the maximum CONST_STRING argument > - encountered. Set *UNKNOWNP and return INT_MAX if the value is unknown. */ > +/* Given an attribute value expression, return the maximum value that > + might be evaluated assuming all conditionals are independent. > + Return INT_MAX if the value can't be calculated by this function. */ Not sure about "assuming all conditionals are independent". All three functions should be conservatively correct without any assumptions. OK without that part if you agree. Thanks, Richard