This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa-branch] Make SSA CCP functional [patch]

On 10 Aug 2002 01:39:11 -0400, Diego Novillo <> wrote:

> On Fri, 2002-08-09 at 20:11, Jason Merrill wrote:
>> On Wed, 7 Aug 2002 14:08:47 -0400, Diego Novillo <> wrote:
>> > 20020807-misc.diff: Unshares references to compound expression
>> >     before simplification.
>> Hmm, this seems to break gcc.c-torture/execute/920428-1.c, since now we
>> evaluate the SAVE_EXPR twice.  What was this for?
> Sorry about that.  I goofed the call to walk_tree.  This was for
> 20020215-1.c:
> 	T.2 = s.i2;
> 	s.i2 = T.2 + 1;
> It turns out that 's' is a constant value and the RHS of the first
> assignment is shared with the LHS of the second.

I don't think that's the right place for the fix.  The problem is that
simplify_self_mod_expr is using s.i2 twice without unsharing.  There's no
need to copy every COMPONENT_REF we encounter.  Patch below, testing now.

This stuff all seems to be rather fragile; I think we need an
unshare_all_trees function, to be called both before and after
simplification.  That should avoid any more problems like this, and produce
less copying into the bargain.  But I won't get to this until I finish the
l-i SIMPLE work.

2002-08-11  Jason Merrill  <>

	* c-simplify.c (simplify_self_mod_expr): Unshare the lhs before
	using it again.
	(simplify_compound_lval): Don't unshare.

*** c-simplify.c.~1~	Sun Aug 11 00:20:50 2002
--- c-simplify.c	Sun Aug 11 01:11:52 2002
*************** simplify_compound_lval (expr_p, pre_p, p
*** 1328,1336 ****
    if (TREE_CODE (*expr_p) != ARRAY_REF && TREE_CODE (*expr_p) != COMPONENT_REF)
      abort ();
-   /* Unshare the reference.  */
-   walk_tree (expr_p, mostly_copy_tree_r, NULL, NULL);
    /* 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");
--- 1336,1341 ----
*************** simplify_self_mod_expr (expr_p, pre_p, p
*** 1394,1399 ****
--- 1399,1407 ----
    /* Extract the operands to the arithmetic operation, including an rvalue
       version of our LHS.  */
    lhs = lvalue;
+   /* Unshare it.  */
+   walk_tree (&lhs, mostly_copy_tree_r, NULL, NULL);
+   /* And reduce it to an ID.  */
    simplify_expr (&lhs, pre_p, post_p, is_simple_id, fb_rvalue);
    rhs = TREE_OPERAND (*expr_p, 1);
    simplify_expr (&rhs, pre_p, post_p, is_simple_val, fb_rvalue);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]