From: Richard Sandiford <richard.sandiford@arm.com>
To: Alan Modra <amodra@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] genattrtab bit-rot, and if_then_else in values
Date: Fri, 04 Jan 2019 12:18:00 -0000 [thread overview]
Message-ID: <87imz4pqf8.fsf@arm.com> (raw)
In-Reply-To: <20190104001952.GB3170@bubble.grove.modra.org> (Alan Modra's message of "Fri, 4 Jan 2019 10:49:52 +1030")
Alan Modra <amodra@gmail.com> writes:
> On Thu, Jan 03, 2019 at 07:03:59PM +0000, Richard Sandiford wrote:
>> Richard Sandiford <richard.sandiford@arm.com> 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))
How about the patch below?
Thanks,
Richard
2019-01-04 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* genattrtab.c (or_attr_value): Replace with...
(attr_value_alignment): ...this new function. Handle PLUS,
MINUS and MULT.
(write_length_unit_log): Update accordingly.
Index: gcc/genattrtab.c
===================================================================
--- gcc/genattrtab.c 2019-01-04 12:16:51.000000000 +0000
+++ gcc/genattrtab.c 2019-01-04 12:16:51.322900008 +0000
@@ -268,7 +268,7 @@ static void insert_insn_ent (stru
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 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);
@@ -1568,24 +1568,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);
}
@@ -3835,16 +3832,16 @@ min_attr_value (rtx exp, int *unknownp)
return current_min;
}
-/* Given an attribute value, return the result of ORing together all
- CONST_STRING arguments encountered. Set *UNKNOWNP and return -1
- if the numeric value is not known. */
+/* Given an attribute value EXP, return the maximum alignment that all
+ values are known to have. Return 0 if EXP is known to be zero. */
-static int
-or_attr_value (rtx exp, int *unknownp)
+static unsigned int
+attr_value_alignment (rtx exp)
{
- int current_or;
+ unsigned int current_or;
int i;
+ /* When breaking, OR the possible alignment values into CURRENT_OR. */
switch (GET_CODE (exp))
{
case CONST_STRING:
@@ -3852,23 +3849,31 @@ or_attr_value (rtx exp, int *unknownp)
break;
case COND:
- current_or = or_attr_value (XEXP (exp, 1), unknownp);
+ current_or = attr_value_alignment (XEXP (exp, 1));
for (i = 0; i < XVECLEN (exp, 0); i += 2)
- current_or |= or_attr_value (XVECEXP (exp, 0, i + 1), unknownp);
+ current_or |= attr_value_alignment (XVECEXP (exp, 0, i + 1));
break;
case IF_THEN_ELSE:
- current_or = or_attr_value (XEXP (exp, 1), unknownp);
- current_or |= or_attr_value (XEXP (exp, 2), unknownp);
+ current_or = attr_value_alignment (XEXP (exp, 1));
+ current_or |= attr_value_alignment (XEXP (exp, 2));
break;
- default:
- *unknownp = 1;
- current_or = -1;
+ case PLUS:
+ case MINUS:
+ current_or = attr_value_alignment (XEXP (exp, 0));
+ current_or |= attr_value_alignment (XEXP (exp, 1));
break;
+
+ case MULT:
+ return (attr_value_alignment (XEXP (exp, 0))
+ * attr_value_alignment (XEXP (exp, 1)));
+
+ default:
+ return 1;
}
- return current_or;
+ return current_or & -current_or;
}
/* Scan an attribute value, possibly a conditional, and record what actions
next prev parent reply other threads:[~2019-01-04 12:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-03 9:22 Alan Modra
2019-01-03 12:41 ` Richard Sandiford
2019-01-03 14:36 ` Alan Modra
2019-01-03 17:08 ` Richard Sandiford
2019-01-03 19:04 ` Richard Sandiford
2019-01-04 0:20 ` Alan Modra
2019-01-04 12:18 ` Richard Sandiford [this message]
2019-01-06 22:36 ` Alan Modra
2019-01-07 12:10 ` Richard Sandiford
2019-01-07 22:31 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87imz4pqf8.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=amodra@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).