scc_copy: conditional return TODO_cleanup_cfg.

Only have cleanup cfg happen if scc copy did some proping.
This should be a small compile time improvement by not doing cleanup
cfg if scc copy does nothing.

Also removes TODO_update_ssa since it should not be needed.

gcc/ChangeLog:

	* gimple-ssa-sccopy.cc (scc_copy_prop::replace_scc_by_value): Return true
	if something was done.
	(scc_copy_prop::propagate): Return true if something was changed.
	(pass_sccopy::execute): Return TODO_cleanup_cfg if a prop happened.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
This commit is contained in:
Andrew Pinski
2025-05-29 15:07:38 -07:00
parent f359866eea
commit 62ed7fb525

View File

@@ -464,7 +464,7 @@ class scc_copy_prop
public:
scc_copy_prop ();
~scc_copy_prop ();
void propagate ();
bool propagate ();
private:
/* Bitmap tracking statements which were propagated so that they can be
@@ -474,15 +474,16 @@ private:
void visit_op (tree op, hash_set<tree> &outer_ops,
hash_set<gimple *> &scc_set, bool &is_inner,
tree &last_outer_op);
void replace_scc_by_value (vec<gimple *> scc, tree val);
bool replace_scc_by_value (vec<gimple *> scc, tree val);
};
/* For each statement from given SCC, replace its usages by value
VAL. */
void
bool
scc_copy_prop::replace_scc_by_value (vec<gimple *> scc, tree val)
{
bool didsomething = false;
for (gimple *stmt : scc)
{
tree name = gimple_get_lhs (stmt);
@@ -497,10 +498,12 @@ scc_copy_prop::replace_scc_by_value (vec<gimple *> scc, tree val)
}
replace_uses_by (name, val);
bitmap_set_bit (dead_stmts, SSA_NAME_VERSION (name));
didsomething = true;
}
if (dump_file)
fprintf (dump_file, "Replacing SCC of size %d\n", scc.length ());
return didsomething;
}
/* Part of 'scc_copy_prop::propagate ()'. */
@@ -566,9 +569,10 @@ scc_copy_prop::visit_op (tree op, hash_set<tree> &outer_ops,
Braun, Buchwald, Hack, Leissa, Mallon, Zwinkau, 2013, LNCS vol. 7791,
Section 3.2. */
void
bool
scc_copy_prop::propagate ()
{
bool didsomething = false;
auto_vec<gimple *> useful_stmts = get_all_stmt_may_generate_copy ();
scc_discovery discovery;
@@ -636,7 +640,7 @@ scc_copy_prop::propagate ()
{
/* The only operand in outer_ops. */
tree outer_op = last_outer_op;
replace_scc_by_value (scc, outer_op);
didsomething |= replace_scc_by_value (scc, outer_op);
}
else if (outer_ops.elements () > 1)
{
@@ -651,6 +655,7 @@ scc_copy_prop::propagate ()
scc.release ();
}
return didsomething;
}
scc_copy_prop::scc_copy_prop ()
@@ -683,7 +688,7 @@ const pass_data pass_data_sccopy =
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
TODO_update_ssa | TODO_cleanup_cfg, /* todo_flags_finish */
0, /* todo_flags_finish */
};
class pass_sccopy : public gimple_opt_pass
@@ -703,8 +708,7 @@ unsigned
pass_sccopy::execute (function *)
{
scc_copy_prop sccopy;
sccopy.propagate ();
return 0;
return sccopy.propagate () ? TODO_cleanup_cfg : 0;
}
} // anon namespace