This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] PATCH to simplify_compound_lval
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 01 Jun 2003 11:56:53 -0400
- Subject: [tree-ssa] PATCH to simplify_compound_lval
Jeff sent me a testcase where TREE_SIDE_EFFECTS was still set on a
COMPONENT_REF which no longer contained a subexpression with side-effects.
This turned out to be because simplify_compound_lval was only calling
recalculate_side_effects on the outermost COMPONENT/ARRAY_REF. Fixed thus.
Tested athlon-pc-linux-gnu, applied to tree-ssa branch.
2003-06-01 Jason Merrill <jason@redhat.com>
* gimplify.c (simplify_compound_lval): Call
recalculate_side_effects on each of the subexpressions.
*** gimplify.c.~1~ Tue May 27 18:51:19 2003
--- gimplify.c Sun Jun 1 02:28:15 2003
*************** simplify_compound_lval (expr_p, pre_p, p
*** 1194,1200 ****
{
tree *p;
enum tree_code code;
! varray_type dim_stack;
#if defined ENABLE_CHECKING
if (TREE_CODE (*expr_p) != ARRAY_REF && TREE_CODE (*expr_p) != COMPONENT_REF)
--- 1194,1200 ----
{
tree *p;
enum tree_code code;
! varray_type stack;
#if defined ENABLE_CHECKING
if (TREE_CODE (*expr_p) != ARRAY_REF && TREE_CODE (*expr_p) != COMPONENT_REF)
*************** simplify_compound_lval (expr_p, pre_p, p
*** 1203,1211 ****
code = ERROR_MARK; /* [GIMPLE] Avoid uninitialized use warning. */
! /* Create a stack with all the array dimensions so that they can be
! simplified from left to right (to match user expectations). */
! VARRAY_GENERIC_PTR_INIT (dim_stack, 10, "dim_stack");
for (p = expr_p;
TREE_CODE (*p) == ARRAY_REF || TREE_CODE (*p) == COMPONENT_REF;
--- 1203,1211 ----
code = ERROR_MARK; /* [GIMPLE] Avoid uninitialized use warning. */
! /* Create a stack of the subexpressions so later we can walk them in
! order from inner to outer. */
! VARRAY_TREE_INIT (stack, 10, "stack");
for (p = expr_p;
TREE_CODE (*p) == ARRAY_REF || TREE_CODE (*p) == COMPONENT_REF;
*************** simplify_compound_lval (expr_p, pre_p, p
*** 1219,1245 ****
/* If the size of the array elements is not constant,
computing the offset is non-trivial, so expose it. */
break;
- VARRAY_PUSH_GENERIC_PTR (dim_stack, (PTR) &TREE_OPERAND (*p, 1));
}
}
/* Now 'p' points to the first bit that isn't an ARRAY_REF or
COMPONENT_REF, 'code' is the TREE_CODE of the last bit that was, and
! 'dim_stack' is a stack of pointers to all the dimensions in left to
! right order (the leftmost dimension is at the top of the stack).
! Simplify the base, and then each of the dimensions from left to
! right. */
simplify_expr (p, pre_p, post_p, is_simple_min_lval,
code == COMPONENT_REF ? fb_either : fb_lvalue);
! for (; VARRAY_ACTIVE_SIZE (dim_stack) > 0; VARRAY_POP (dim_stack))
{
! tree *dim_p = (tree *)VARRAY_TOP_GENERIC_PTR (dim_stack);
! simplify_expr (dim_p, pre_p, post_p, is_simple_val, fb_rvalue);
}
-
- recalculate_side_effects (*expr_p);
}
/* Simplify the self modifying expression pointed by EXPR_P (++, --, +=, -=).
--- 1219,1248 ----
/* If the size of the array elements is not constant,
computing the offset is non-trivial, so expose it. */
break;
}
+ VARRAY_PUSH_TREE (stack, *p);
}
/* Now 'p' points to the first bit that isn't an ARRAY_REF or
COMPONENT_REF, 'code' is the TREE_CODE of the last bit that was, and
! 'stack' is a stack of pointers to all the ARRAY_REFs and
! COMPONENT_REFs we've walked through.
! Simplify the base, and then process each of the outer nodes from left
! to right. */
simplify_expr (p, pre_p, post_p, is_simple_min_lval,
code == COMPONENT_REF ? fb_either : fb_lvalue);
! for (; VARRAY_ACTIVE_SIZE (stack) > 0; VARRAY_POP (stack))
{
! tree t = VARRAY_TOP_TREE (stack);
! if (TREE_CODE (t) == ARRAY_REF)
! /* Simplify the dimension. */
! simplify_expr (&TREE_OPERAND (t, 1), pre_p, post_p, is_simple_val,
! fb_rvalue);
! /* Update TREE_SIDE_EFFECTS. */
! recalculate_side_effects (t);
}
}
/* Simplify the self modifying expression pointed by EXPR_P (++, --, +=, -=).