From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 0B1F43839422 for ; Thu, 22 Jul 2021 12:56:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0B1F43839422 Received: by mail-ed1-x531.google.com with SMTP id l1so6645986edr.11 for ; Thu, 22 Jul 2021 05:56:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gACOqg0y56BwMt5JKpB6CvQ+bq4ZzjUF4mFXIIsQnkg=; b=kc9sE2AabvmS3HxhNzSykbzwQYQS+tAEi8SMKdgsD8Le+kAAZ9chpPtI8CqAr08VQB ZDL4oypzq/6+8yjcsqaSabWu32yU1O7P4NHxLCVIIJiWfSAJaOMvk1rUsxfpVftsPumB xmAF/sVH37blRBG1eAO47V5OkzopmFCHw/f6DOPkG+qhUxsA8k+ShH97mG+TzY++Hb44 BpzShT4E+vPSPkrjSXvB8XD9+ODd3sZux1nbcLlesWhzUyuJQ0JNMJnQ0dWbRIrGsfnA HHh8AKiZzedX0IWnBzcQCOW9EVaEcMm8GpAwP6cZ43HQ8vG7WGKv61yb2twnC3SYO10y 1Hjg== X-Gm-Message-State: AOAM531oyfAOERhQRG7hSheafnEq/dgQc8sGPPc7pZfeaqFmirlBXuY7 wEyP+8hvxp2CRa9TQ+S5Ciz22/m4oW8tl8asGbM= X-Google-Smtp-Source: ABdhPJyAZ2f/BDUnWKp1Ywe4nUMdPYnWm8uXtcz2J/84zNdfbL2JyqmvsrmMUHgoA/XTL+rdJSzBTMu1Ten1IIrbF6A= X-Received: by 2002:a05:6402:3d4:: with SMTP id t20mr54476772edw.274.1626958615083; Thu, 22 Jul 2021 05:56:55 -0700 (PDT) MIME-Version: 1.0 References: <0a8b77ba-1d54-1eff-b54d-d2cb1e769e09@linux.ibm.com> In-Reply-To: From: Richard Biener Date: Thu, 22 Jul 2021 14:56:44 +0200 Message-ID: Subject: Re: [PATCH v2] Use range-based for loops for traversing loops To: "Kewen.Lin" Cc: GCC Patches , Jakub Jelinek , Jonathan Wakely , Segher Boessenkool , Richard Sandiford , Trevor Saunders , Martin Sebor , Bill Schmidt Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2021 12:56:57 -0000 On Thu, Jul 22, 2021 at 2:56 PM Richard Biener wrote: > > On Tue, Jul 20, 2021 at 4:37 > PM Kewen.Lin wrote: > > > > Hi, > > > > This v2 has addressed some review comments/suggestions: > > > > - Use "!=" instead of "<" in function operator!= (const Iter &rhs) > > - Add new CTOR loops_list (struct loops *loops, unsigned flags) > > to support loop hierarchy tree rather than just a function, > > and adjust to use loops* accordingly. > > I actually meant struct loop *, not struct loops * ;) At the point > we pondered to make loop invariant motion work on single > loop nests we gave up not only but also because it iterates > over the loop nest but all the iterators only ever can process > all loops, not say, all loops inside a specific 'loop' (and > including that 'loop' if LI_INCLUDE_ROOT). So the > CTOR would take the 'root' of the loop tree as argument. > > I see that doesn't trivially fit how loops_list works, at least > not for LI_ONLY_INNERMOST. But I guess FROM_INNERMOST > could be adjusted to do ONLY_INNERMOST as well? Oh, just to say - simply leave out the extra CTOR for now. > > - Make implicit 'cfun' become explicit. > > - Get rid of macros ALL_LOOPS*, use loops_list instance. > > - Add const_iterator type begin()/end(). > > - Use class loop* instead of loop_p in range-based for. > > > > 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. > > > > Does it look better? Is it ok for trunk? > > > > 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.