Question on cfg_remove_useless_stmts_bb
Jeffrey A Law
law@redhat.com
Tue Aug 17 15:49:00 GMT 2004
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;
More information about the Gcc
mailing list