On 5/16/19 10:17 PM, Feng Xue OS wrote: > This patch is meant to give user a way to optimize away those empty loops > which are impossible to be recognized by compiler, such as C++ STL > container-based loop, > > void f (std::map<int, int> &m) > { > for (auto it = m.begin (); it != m.end (); ++it); > } > > An option "-ffinite-loop" is added to tell compiler about finiteness of loops > so that compiler can apply the optimization. > > Feng > > diff --git a/gcc/ChangeLog b/gcc/ChangeLog > index d8bed3a..c55f2e6 100644 > --- a/gcc/ChangeLog > +++ b/gcc/ChangeLog > @@ -1,3 +1,18 @@ > +2019-05-16 Feng Xue <f...@os.amperecomputing.com> > + > + PR tree-optimization/89713 > + * doc/invoke.texi (-ffinite-loop): Document new option. > + * common.opt (-ffinite-loop): New option. > + * passes.def: Replace pass_cd_dce with pass_cd_dce2. > + * tree-pass.h (pass_cd_dce2): New declaration. > + * tree-ssa-dce.c (loop_has_true_exits): New function. > + (find_obviously_necessary_stmts): Add aggressive_loop_removal > + parameter. > + (perform_tree_ssa_dce, tree_ssa_cd_dce): Likewise. > + (class pass_cd_dce): Add new member aggressive_loop_removal. > + (pass_cd_dce::pass_cd_dce: Add alr parameter. > + (make_pass_cd_dce2): New function. I'm not a big fan of this patch. I'd rather be looking at either improving our analysis or adding attributes to the loops to help the analysis bits prove termination.
Jeff