This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ast-optimizer-branch]: Simplify STMT_EXPR's
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Sebastian Pop <m1sp at csc dot liv dot ac dot uk>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 2 May 2002 11:56:48 -0400 (EDT)
- Subject: Re: [ast-optimizer-branch]: Simplify STMT_EXPR's
On Thu, 2 May 2002, Sebastian Pop wrote:
> On Thu, May 02, 2002 at 10:34:44AM -0400, Daniel Berlin wrote:
> >
> > but during rtl expansion, it aborts failing the following test in
> > varasm.c:
> >
> > /* Check that we are not being given an automatic variable. */
> > /* A weak alias has TREE_PUBLIC set but not the other bits. */
> > if (TREE_CODE (decl) == PARM_DECL
> > || TREE_CODE (decl) == RESULT_DECL
> > || (TREE_CODE (decl) == VAR_DECL
> > && !TREE_STATIC (decl)
> > && !TREE_PUBLIC (decl)
> > && !DECL_EXTERNAL (decl)
> > && !DECL_REGISTER (decl)))
> > abort ();
> >
> That's what happens also when some of the DECL_STMTs were deleted after
> statement rechaining.
>
> Maybe the error comes from the following ? Can you check ?
>
> TREE_CHAIN (new_stmt) = TREE_CHAIN (temp);
> TREE_CHAIN (temp) = new_stmt;
Doesn't this turn:
temp
stmt_2
into
temp
new_stmt
stmt_2
?
I wrote it around 2am, so it's quite possible i wasn't thinking at all.
Basically, it's trying to turn:
...
x = y;
}
into
...
x = y;
<new temp> = x;
}
Let me see if it works for the case of
...
x;
}
where we transform it into
...
<new temporary> = x;
}
without inserting anything (IE we directly modify the tree for x,
rather than chain a new stmt in. )
>
> You cannot really trust on the prety printer since it prints variable declarations
> from the SCOPE_STMT's BLOCK and doesn't print anything for a DECL_STMT.
> So the only way to know wether you removed or not some DECL_STMTs is to use the
> debug_tree (). Maybe I have to rewrite this portion of the pretty printer
> since it is missleading.
Ahhhh.
Wasn't aware of that.
>
> You no longer use 'temp', nor "last" in the following,
> and the code above has no side effects.
YUp, thanks, I wasn't paying attention.
>
> > + expr_s = NULL_TREE;
> > + add_tree (STMT_EXPR_STMT (expr), pre_p);
> > + return expr_s;
> > + }
> So I suggest :
> else
> {
> expr_s = NULL_TREE;
> add_tree (STMT_EXPR_STMT (expr), pre_p);
> return expr_s;
> }
>
> that can be transformed into :
> else
> {
> add_tree (STMT_EXPR_STMT (expr), pre_p);
> return NULL_TREE;
> }
> > break;
> >
> > case SAVE_EXPR:
> > *************** static int
> > *** 2478,2483 ****
> > --- 2546,2553 ----
> > expr_has_effect (expr)
> > tree expr;
> > {
> > + if (expr == NULL_TREE)
> > + return 0;
> > return (TREE_SIDE_EFFECTS (expr)
> > || (TREE_CODE (expr) == CONVERT_EXPR
> > && VOID_TYPE_P (TREE_TYPE (expr))));
> >
>