## Comments

## Patch

===================================================================
@@ -173,6 +173,32 @@ variable_size (tree size)
/* An array of functions used for self-referential size computation. */
static GTY(()) VEC (tree, gc) *size_functions;
+/* Look inside EXPR into simple arithmetic operations involving constants.
+ Return the outermost non-arithmetic or non-constant node. */
+
+static tree
+skip_simple_constant_arithmetic (tree expr)
+{
+ while (true)
+ {
+ if (UNARY_CLASS_P (expr))
+ expr = TREE_OPERAND (expr, 0);
+ else if (BINARY_CLASS_P (expr))
+ {
+ if (TREE_CONSTANT (TREE_OPERAND (expr, 1)))
+ expr = TREE_OPERAND (expr, 0);
+ else if (TREE_CONSTANT (TREE_OPERAND (expr, 0)))
+ expr = TREE_OPERAND (expr, 1);
+ else
+ break;
+ }
+ else
+ break;
+ }
+
+ return expr;
+}
+
/* Similar to copy_tree_r but do not copy component references involving
PLACEHOLDER_EXPRs. These nodes are spotted in find_placeholder_in_expr
and substituted in substitute_in_expr. */
@@ -241,7 +267,7 @@ self_referential_size (tree size)
VEC(tree,gc) *args = NULL;
/* Do not factor out simple operations. */
- t = skip_simple_arithmetic (size);
+ t = skip_simple_constant_arithmetic (size);
if (TREE_CODE (t) == CALL_EXPR)
return size;