This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question on cfg_remove_useless_stmts_bb
- From: Jeffrey A Law <law at redhat dot com>
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 17 Aug 2004 09:05:05 -0600
- Subject: Re: Question on cfg_remove_useless_stmts_bb
- Organization: Red Hat, Inc
- References: <10408171057.AA07608@vlsi1.ultra.nyu.edu>
- Reply-to: law at redhat dot com
On Tue, 2004-08-17 at 04:57, Richard Kenner wrote:
> if (TREE_CODE (stmt) == ASM_EXPR
> || (TREE_CODE (stmt) == MODIFY_EXPR
> && (TREE_OPERAND (stmt, 0) == var
> || TREE_CODE (stmt, 0) == val)))
>
> Ought to do the trick.
>
> In this case, yes, but I'm not convinced that it's complete. Couldn't
> VAL be a more complex expression here and we have to verify that none of
> its operands were modified? That issue is basically the other motivation
> for my query (the primary one being, of course, "how did this ever work?"!).
VAL can only be a _DECL node or a constant.
if (TREE_CODE (cond) == VAR_DECL || TREE_CODE (cond) == PARM_DECL)
{
var = cond;
val = (bb->pred->flags & EDGE_FALSE_VALUE
? boolean_false_node : boolean_true_node);
}
else if (TREE_CODE (cond) == TRUTH_NOT_EXPR
&& (TREE_CODE (TREE_OPERAND (cond, 0)) == VAR_DECL
|| TREE_CODE (TREE_OPERAND (cond, 0)) == PARM_DECL))
{
var = TREE_OPERAND (cond, 0);
val = (bb->pred->flags & EDGE_FALSE_VALUE
? boolean_true_node : boolean_false_node);
}
else
{
if (bb->pred->flags & EDGE_FALSE_VALUE)
cond = invert_truthvalue (cond);
if (TREE_CODE (cond) == EQ_EXPR
&& (TREE_CODE (TREE_OPERAND (cond, 0)) == VAR_DECL
|| TREE_CODE (TREE_OPERAND (cond, 0)) == PARM_DECL)
&& (TREE_CODE (TREE_OPERAND (cond, 1)) == VAR_DECL
|| TREE_CODE (TREE_OPERAND (cond, 1)) == PARM_DECL
|| TREE_CONSTANT (TREE_OPERAND (cond, 1))))
{
var = TREE_OPERAND (cond, 0);
val = TREE_OPERAND (cond, 1);
}
else
return;