public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Kewen.Lin" <linkw@linux.ibm.com>
Cc: Martin Sebor <msebor@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	 Jakub Jelinek <jakub@redhat.com>,
	Jonathan Wakely <jwakely.gcc@gmail.com>,
	 Segher Boessenkool <segher@kernel.crashing.org>,
	Richard Sandiford <richard.sandiford@arm.com>,
	 Bill Schmidt <wschmidt@linux.ibm.com>,
	Trevor Saunders <tbsaunde@tbsaunde.org>
Subject: Re: [PATCH v4] Use range-based for loops for traversing loops
Date: Thu, 29 Jul 2021 09:48:10 +0200	[thread overview]
Message-ID: <CAFiYyc0u0JdqGW7QuiZaafaQhk1p++HD80Ba-C+c=QugFJPqAw@mail.gmail.com> (raw)
In-Reply-To: <eb07c2a6-054a-28d7-3f89-867fadba4194@linux.ibm.com>

On Tue, Jul 27, 2021 at 4:11 AM Kewen.Lin <linkw@linux.ibm.com> wrote:
>
> on 2021/7/24 上午12:10, Martin Sebor wrote:
> > On 7/23/21 2:35 AM, Kewen.Lin wrote:
> >> Hi,
> >>
> >> Comparing to v2, this v3 removed the new CTOR with struct loops *loops
> >> as Richi clarified.  I'd like to support it in a separated follow up
> >> patch by extending the existing CTOR with an optional argument loop_p
> >> root.
> >
> > Looks very nice (and quite a bit work)!  Thanks again!
> >
> > Not to make even more work for you, but it occurred to me that
> > the declaration of the loop control variable could be simplified
> > by the use of auto like so:
> >
> >  for (auto loop: loops_list (cfun, ...))
> >
>
> Thanks for the suggestion!  Updated in v4 accordingly.
>
> I was under the impression to use C++11 auto is arguable since it sometimes
> may make things less clear.  But I think you are right, using auto here won't
> make it harder to read but more concise.  Thanks again.
>
> > I spotted what looks to me like a few minor typos in the docs
> > diff:
> >
> > diff --git a/gcc/doc/loop.texi b/gcc/doc/loop.texi
> > index a135656ed01..27697b08728 100644
> > --- a/gcc/doc/loop.texi
> > +++ b/gcc/doc/loop.texi
> > @@ -79,14 +79,14 @@ and its subloops in the numbering.  The index of a loop never changes.
> >
> > The entries of the @code{larray} field should not be accessed directly.
> > The function @code{get_loop} returns the loop description for a loop with
> > -the given index.  @code{number_of_loops} function returns number of
> > -loops in the function.  To traverse all loops, use @code{FOR_EACH_LOOP}
> > -macro.  The @code{flags} argument of the macro is used to determine
> > -the direction of traversal and the set of loops visited.  Each loop is
> > -guaranteed to be visited exactly once, regardless of the changes to the
> > -loop tree, and the loops may be removed during the traversal.  The newly
> > -created loops are never traversed, if they need to be visited, this
> > -must be done separately after their creation.
> > +the given index.  @code{number_of_loops} function returns number of loops
> > +in the function.  To traverse all loops, use range-based for loop with
> >
> > Missing article:
> >
> >   use <ins>a </a>range-based for loop
> >
> > +class @code{loop_list} instance. The @code{flags} argument of the macro
> >
> > Is that loop_list or loops_list?
> >
> > IIUC, it's also not a macro anymore, right?  The flags argument
> > is passed to the loop_list ctor, no?
> >
>
> Oops, thanks for catching all above ones!  Fixed in v4.
>
> Bootstrapped and regtested again on powerpc64le-linux-gnu P9,
> x86_64-redhat-linux and aarch64-linux-gnu, also
> bootstrapped again on ppc64le P9 with bootstrap-O3 config.
>
> Is it ok for trunk?

OK.

Thanks,
Richard.

> BR,
> Kewen
> -----
> gcc/ChangeLog:
>
>         * cfgloop.h (as_const): New function.
>         (class loop_iterator): Rename to ...
>         (class loops_list): ... this.
>         (loop_iterator::next): Rename to ...
>         (loops_list::Iter::fill_curr_loop): ... this and adjust.
>         (loop_iterator::loop_iterator): Rename to ...
>         (loops_list::loops_list): ... this and adjust.
>         (loops_list::Iter): New class.
>         (loops_list::iterator): New type.
>         (loops_list::const_iterator): New type.
>         (loops_list::begin): New function.
>         (loops_list::end): Likewise.
>         (loops_list::begin const): Likewise.
>         (loops_list::end const): Likewise.
>         (FOR_EACH_LOOP): Remove.
>         (FOR_EACH_LOOP_FN): Remove.
>         * cfgloop.c (flow_loops_dump): Adjust FOR_EACH_LOOP* with range-based
>         for loop with loops_list instance.
>         (sort_sibling_loops): Likewise.
>         (disambiguate_loops_with_multiple_latches): Likewise.
>         (verify_loop_structure): Likewise.
>         * cfgloopmanip.c (create_preheaders): Likewise.
>         (force_single_succ_latches): Likewise.
>         * config/aarch64/falkor-tag-collision-avoidance.c
>         (execute_tag_collision_avoidance): Likewise.
>         * config/mn10300/mn10300.c (mn10300_scan_for_setlb_lcc): Likewise.
>         * config/s390/s390.c (s390_adjust_loops): Likewise.
>         * doc/loop.texi: Likewise.
>         * gimple-loop-interchange.cc (pass_linterchange::execute): Likewise.
>         * gimple-loop-jam.c (tree_loop_unroll_and_jam): Likewise.
>         * gimple-loop-versioning.cc (loop_versioning::analyze_blocks): Likewise.
>         (loop_versioning::make_versioning_decisions): Likewise.
>         * gimple-ssa-split-paths.c (split_paths): Likewise.
>         * graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): Likewise.
>         * graphite.c (canonicalize_loop_form): Likewise.
>         (graphite_transform_loops): Likewise.
>         * ipa-fnsummary.c (analyze_function_body): Likewise.
>         * ipa-pure-const.c (analyze_function): Likewise.
>         * loop-doloop.c (doloop_optimize_loops): Likewise.
>         * loop-init.c (loop_optimizer_finalize): Likewise.
>         (fix_loop_structure): Likewise.
>         * loop-invariant.c (calculate_loop_reg_pressure): Likewise.
>         (move_loop_invariants): Likewise.
>         * loop-unroll.c (decide_unrolling): Likewise.
>         (unroll_loops): Likewise.
>         * modulo-sched.c (sms_schedule): Likewise.
>         * predict.c (predict_loops): Likewise.
>         (pass_profile::execute): Likewise.
>         * profile.c (branch_prob): Likewise.
>         * sel-sched-ir.c (sel_finish_pipelining): Likewise.
>         (sel_find_rgns): Likewise.
>         * tree-cfg.c (replace_loop_annotate): Likewise.
>         (replace_uses_by): Likewise.
>         (move_sese_region_to_fn): Likewise.
>         * tree-if-conv.c (pass_if_conversion::execute): Likewise.
>         * tree-loop-distribution.c (loop_distribution::execute): Likewise.
>         * tree-parloops.c (parallelize_loops): Likewise.
>         * tree-predcom.c (tree_predictive_commoning): Likewise.
>         * tree-scalar-evolution.c (scev_initialize): Likewise.
>         (scev_reset): Likewise.
>         * tree-ssa-dce.c (find_obviously_necessary_stmts): Likewise.
>         * tree-ssa-live.c (remove_unused_locals): Likewise.
>         * tree-ssa-loop-ch.c (ch_base::copy_headers): Likewise.
>         * tree-ssa-loop-im.c (analyze_memory_references): Likewise.
>         (tree_ssa_lim_initialize): Likewise.
>         * tree-ssa-loop-ivcanon.c (canonicalize_induction_variables): Likewise.
>         * tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Likewise.
>         * tree-ssa-loop-manip.c (get_loops_exits): Likewise.
>         * tree-ssa-loop-niter.c (estimate_numbers_of_iterations): Likewise.
>         (free_numbers_of_iterations_estimates): Likewise.
>         * tree-ssa-loop-prefetch.c (tree_ssa_prefetch_arrays): Likewise.
>         * tree-ssa-loop-split.c (tree_ssa_split_loops): Likewise.
>         * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Likewise.
>         * tree-ssa-loop.c (gate_oacc_kernels): Likewise.
>         (pass_scev_cprop::execute): Likewise.
>         * tree-ssa-propagate.c (clean_up_loop_closed_phi): Likewise.
>         * tree-ssa-sccvn.c (do_rpo_vn): Likewise.
>         * tree-ssa-threadupdate.c
>         (jump_thread_path_registry::thread_through_all_blocks): Likewise.
>         * tree-vectorizer.c (vectorize_loops): Likewise.
>         * tree-vrp.c (vrp_asserts::find_assert_locations): Likewise.

  reply	other threads:[~2021-07-29  7:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19  6:20 [RFC/PATCH] " Kewen.Lin
2021-07-19  6:26 ` Andrew Pinski
2021-07-20  8:56   ` Kewen.Lin
2021-07-19 14:08 ` Jonathan Wakely
2021-07-20  8:56   ` Kewen.Lin
2021-07-19 14:34 ` Richard Biener
2021-07-20  8:57   ` Kewen.Lin
2021-07-19 15:59 ` Martin Sebor
2021-07-20  8:58   ` Kewen.Lin
2021-07-20  9:49     ` Jonathan Wakely
2021-07-20  9:50       ` Jonathan Wakely
2021-07-20 14:42       ` Kewen.Lin
2021-07-20 14:36 ` [PATCH v2] " Kewen.Lin
2021-07-22 12:56   ` Richard Biener
2021-07-22 12:56     ` Richard Biener
2021-07-23  8:41     ` [PATCH] Make loops_list support an optional loop_p root Kewen.Lin
2021-07-23 16:26       ` Martin Sebor
2021-07-27  2:25         ` Kewen.Lin
2021-07-29  8:01       ` Richard Biener
2021-07-30  5:20         ` [PATCH v2] " Kewen.Lin
2021-08-03 12:08           ` Richard Biener
2021-08-04  2:36             ` [PATCH v3] " Kewen.Lin
2021-08-04 10:01               ` Richard Biener
2021-08-04 10:47                 ` Kewen.Lin
2021-08-04 12:04                   ` Richard Biener
2021-08-05  8:50                     ` Kewen.Lin
2021-07-23  8:35   ` [PATCH v3] Use range-based for loops for traversing loops Kewen.Lin
2021-07-23 16:10     ` Martin Sebor
2021-07-27  2:10       ` [PATCH v4] " Kewen.Lin
2021-07-29  7:48         ` Richard Biener [this message]
2021-07-30  7:18         ` Thomas Schwinge
2021-07-30  7:58           ` Kewen.Lin
2021-11-24 14:24             ` Reduce scope of a few 'class loop *loop' variables (was: [PATCH v4] Use range-based for loops for traversing loops) Thomas Schwinge
2021-11-24 16:58               ` Martin Jambor
2021-11-24 19:44               ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc0u0JdqGW7QuiZaafaQhk1p++HD80Ba-C+c=QugFJPqAw@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jwakely.gcc@gmail.com \
    --cc=linkw@linux.ibm.com \
    --cc=msebor@gmail.com \
    --cc=richard.sandiford@arm.com \
    --cc=segher@kernel.crashing.org \
    --cc=tbsaunde@tbsaunde.org \
    --cc=wschmidt@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).