On Fri, May 30, 2025 at 3:53 AM Andrew Pinski <quic_apin...@quicinc.com> wrote: > > 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.
OK. Richard. > 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_apin...@quicinc.com> > --- > gcc/gimple-ssa-sccopy.cc | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > > diff --git a/gcc/gimple-ssa-sccopy.cc b/gcc/gimple-ssa-sccopy.cc > index ee2a7fa8a72..c93374572a9 100644 > --- a/gcc/gimple-ssa-sccopy.cc > +++ b/gcc/gimple-ssa-sccopy.cc > @@ -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 > -- > 2.43.0 >