summaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-21 06:32:54 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-21 06:32:54 +0000
commit0353bcea3894f3e2e70f1a19fa95b84db20b3f3e (patch)
tree379bc935342ebf1d5878640474035e1204555845 /gcc/stor-layout.c
parenta6e60f51f8bf4ad1960cf29dc4d20847b8b9f1b8 (diff)
downloadgcc-0353bcea3894f3e2e70f1a19fa95b84db20b3f3e.tar.gz
2010-10-21 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 165748 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@165750 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 5796ea1f09a..f3663185e68 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -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;