public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com
Subject: Re: [PATCH] genattrtab bit-rot, and if_then_else in values
Date: Fri, 04 Jan 2019 00:20:00 -0000	[thread overview]
Message-ID: <20190104001952.GB3170@bubble.grove.modra.org> (raw)
In-Reply-To: <87h8epr2ao.fsf@arm.com>

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?

diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index c86b3587cd9..2a81445a160 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -3750,8 +3750,9 @@ write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags,
   return attrs_cached;
 }
 
-/* Given an attribute value, return the maximum CONST_INT or CONST_STRING
-   argument encountered.  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.  */
 
 static int
 max_attr_value (rtx exp)
@@ -3805,8 +3806,9 @@ max_attr_value (rtx exp)
   return current_max;
 }
 
-/* Given an attribute value, return the minimum CONST_INT or CONST_STRING
-   argument encountered.  Return INT_MIN if the value is unknown.  */
+/* Given an attribute value expression, return the minimum value that
+   might be evaluated assuming all conditionals are independent.
+   Return INT_MIN if the value can't be calculated by this function.  */
 
 static int
 min_attr_value (rtx exp)
@@ -3860,9 +3862,18 @@ min_attr_value (rtx exp)
   return current_min;
 }
 
-/* Given an attribute value, return the result of ORing together all
-   CONST_INT or CONST_STRING arguments encountered.  Return -1 if the
-   numeric value is not known.  */
+/* Given an attribute value expression, return the result of ORing
+   together all CONST_INT or CONST_STRING arguments encountered in the
+   value parts of the expression.  (ie. excluding those that might be
+   found in condition expressions of COND or IF_THEN_ELSE.)  Note that
+   this isn't the same as the OR of all possible evaluations of the
+   expression, but is sufficient for the current use of this function
+   in calculating the largest power of two that divides insn lengths.
+   ie.  We are calculating a property of the underlying machine
+   instructions emitted by gcc.  In particular this implementation
+   assumes conditionals are independent and that the operands of a
+   PLUS are multiples of the underlying machine instruction length.
+   Returns -1 if the value can't be calculated by this function.  */
 
 static int
 or_attr_value (rtx exp)
@@ -3882,13 +3893,7 @@ or_attr_value (rtx exp)
 
     case PLUS:
       current_or = or_attr_value (XEXP (exp, 0));
-      if (current_or != -1)
-	{
-	  int n = current_or;
-	  current_or = or_attr_value (XEXP (exp, 1));
-	  if (current_or != -1)
-	    current_or += n;
-	}
+      current_or |= or_attr_value (XEXP (exp, 1));
       break;
 
     case COND:

  reply	other threads:[~2019-01-04  0:20 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 [this message]
2019-01-04 12:18           ` Richard Sandiford
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=20190104001952.GB3170@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.sandiford@arm.com \
    /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).