On Thu, Jan 03, 2019 at 07:03:59PM +0000, Richard Sandiford wrote: > Richard Sandiford <richard.sandif...@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: