}
/* STMT is a statement of the form SSA_NAME = ADDR_EXPR <whatever>.
+ SOME is a pointer to a boolean value indicating whether we
+ propagated the address expression anywhere.
Try to forward propagate the ADDR_EXPR into all uses of the SSA_NAME.
Often this will allow for removal of an ADDR_EXPR and INDIRECT_REF
Returns true, if all uses have been propagated into. */
static bool
-forward_propagate_addr_expr (tree stmt)
+forward_propagate_addr_expr (tree stmt, bool *some)
{
int stmt_loop_depth = bb_for_stmt (stmt)->loop_depth;
tree name = TREE_OPERAND (stmt, 0);
- use_operand_p imm_use;
imm_use_iterator iter;
+ tree use_stmt;
bool all = true;
- FOR_EACH_IMM_USE_SAFE (imm_use, iter, name)
+ FOR_EACH_IMM_USE_STMT (use_stmt, iter, name)
{
- tree use_stmt = USE_STMT (imm_use);
+ bool result;
/* If the use is not in a simple assignment statement, then
there is nothing we can do. */
all = false;
continue;
}
-
- all = forward_propagate_addr_expr_1 (stmt, use_stmt) && all;
+
+ result = forward_propagate_addr_expr_1 (stmt, use_stmt);
+ if (some)
+ *some |= result;
+ all &= result;
}
return all;
/* Main entry point for the forward propagation optimizer. */
-static void
+static unsigned int
tree_ssa_forward_propagate_single_use_vars (void)
{
basic_block bb;
+ unsigned int todoflags = 0;
cfg_changed = false;
if (TREE_CODE (rhs) == ADDR_EXPR)
{
- if (forward_propagate_addr_expr (stmt))
+ bool some = false;
+ if (forward_propagate_addr_expr (stmt, &some))
bsi_remove (&bsi, true);
else
bsi_next (&bsi);
+ if (some)
+ todoflags |= TODO_update_smt_usage;
}
else if ((TREE_CODE (rhs) == BIT_NOT_EXPR
|| TREE_CODE (rhs) == NEGATE_EXPR)
if (cfg_changed)
cleanup_tree_cfg ();
+ return todoflags;
}
PROP_cfg | PROP_ssa
| PROP_alias, /* properties_required */
0, /* properties_provided */
- 0, /* properties_destroyed */
+ PROP_smt_usage, /* properties_destroyed */
0, /* todo_flags_start */
- TODO_dump_func | TODO_ggc_collect /* todo_flags_finish */
+ TODO_dump_func /* todo_flags_finish */
+ | TODO_ggc_collect
| TODO_update_ssa | TODO_verify_ssa,
0 /* letter */
};