On Thu, Dec 11, 2025 at 2:30 PM Victor Do Nascimento
<[email protected]> wrote:
>
> New in this revision:
>   - Make use use of `loop_exits_from_bb_p' to simplify finding the
>   main exit when handling uncounted loops.

LGTM now.

> --------------------
>
> In its current implementation, the loop vectorizer requires the main
> exit be the counting IV exit. With uncounted loops we no longer need
> to have any counting IV exits.  Furthermore, it is possible to have
> reached this stage with malformed loops with no exits at all.
>
> Consequently, we need an approach to handle malformed loops and some
> logic to follow when choosing the main exit, when counting IV is no
> longer a valid criterion.
>
> For malformed loops, it is sufficient to return NULL, so that we can
> reject such loops upon the function return.
>
> In the case of multiple exits and no counting IV exit, we choose the
> last one in the loop.  This is done so that we continue to have an
> empty effective latch.
>
> As a consequence of allowing the main exit to no longer be associated
> with IV counting, the old nomenclature of `LOOP_VINFO_IV_EXIT' and
> `vec_loop_iv_exit' no longer fully cover the usage of such fields and
> accessors.  With that in mind, these are modified to replace "IV" for
> "MAIN" for these.
>
> gcc/ChangeLog:
>
>         * tree-vect-loop.cc (vec_init_loop_exit_info): Handle
>         multiple-exit uncounted loops.
>         * tree-vect-loop.cc (vec_init_loop_exit_info): Handle
>         ill-formed loops with no exits.
>         (vect_analyze_loop_form): Fix `failure_at' message.
> ---
>  gcc/tree-vect-data-refs.cc  |  2 +-
>  gcc/tree-vect-loop-manip.cc | 34 +++++++++++------------
>  gcc/tree-vect-loop.cc       | 55 ++++++++++++++++++++++---------------
>  gcc/tree-vectorizer.cc      |  2 +-
>  gcc/tree-vectorizer.h       | 26 +++++++++---------
>  5 files changed, 65 insertions(+), 54 deletions(-)
>
> diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
> index b35ba05fd08..154bf5ac1b6 100644
> --- a/gcc/tree-vect-data-refs.cc
> +++ b/gcc/tree-vect-data-refs.cc
> @@ -2590,7 +2590,7 @@ vect_enhance_data_refs_alignment (loop_vec_info 
> loop_vinfo)
>
>    /* Check if we can possibly peel the loop.  */
>    if (!vect_can_advance_ivs_p (loop_vinfo)
> -      || !slpeel_can_duplicate_loop_p (loop, LOOP_VINFO_IV_EXIT (loop_vinfo),
> +      || !slpeel_can_duplicate_loop_p (loop, LOOP_VINFO_MAIN_EXIT 
> (loop_vinfo),
>                                        loop_preheader_edge (loop))
>        || loop->inner
>        /* We don't currently maintaing the LCSSA for prologue peeled inversed
> diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
> index cdcfc8d0015..2235cf2f096 100644
> --- a/gcc/tree-vect-loop-manip.cc
> +++ b/gcc/tree-vect-loop-manip.cc
> @@ -545,7 +545,7 @@ vect_set_loop_controls_directly (class loop *loop, 
> loop_vec_info loop_vinfo,
>    tree index_before_incr, index_after_incr;
>    gimple_stmt_iterator incr_gsi;
>    bool insert_after;
> -  edge exit_e = LOOP_VINFO_IV_EXIT (loop_vinfo);
> +  edge exit_e = LOOP_VINFO_MAIN_EXIT (loop_vinfo);
>    vect_iv_increment_position (exit_e, &incr_gsi, &insert_after);
>    if (LOOP_VINFO_USING_DECREMENTING_IV_P (loop_vinfo))
>      {
> @@ -2935,7 +2935,7 @@ vect_gen_vector_loop_niters_mult_vf (loop_vec_info 
> loop_vinfo,
>    int vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo).to_constant ();
>    tree type = TREE_TYPE (niters_vector);
>    tree tree_vf = build_int_cst (type, vf);
> -  basic_block exit_bb = LOOP_VINFO_IV_EXIT (loop_vinfo)->dest;
> +  basic_block exit_bb = LOOP_VINFO_MAIN_EXIT (loop_vinfo)->dest;
>
>    gcc_assert (niters_vector_mult_vf_ptr != NULL);
>    tree niters_vector_mult_vf = fold_build2 (MULT_EXPR, type,
> @@ -3362,19 +3362,19 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree 
> niters, tree nitersm1,
>          use the original scalar loop as remaining epilogue if necessary.  */
>        LOOP_VINFO_SCALAR_LOOP (epilogue_vinfo)
>         = LOOP_VINFO_SCALAR_LOOP (loop_vinfo);
> -      LOOP_VINFO_SCALAR_IV_EXIT (epilogue_vinfo)
> -       = LOOP_VINFO_SCALAR_IV_EXIT (loop_vinfo);
> +      LOOP_VINFO_SCALAR_MAIN_EXIT (epilogue_vinfo)
> +       = LOOP_VINFO_SCALAR_MAIN_EXIT (loop_vinfo);
>      }
>
>    if (prolog_peeling)
>      {
>        e = loop_preheader_edge (loop);
> -      edge exit_e = LOOP_VINFO_IV_EXIT (loop_vinfo);
> +      edge exit_e = LOOP_VINFO_MAIN_EXIT (loop_vinfo);
>        gcc_checking_assert (slpeel_can_duplicate_loop_p (loop, exit_e, e)
>                            && !LOOP_VINFO_EARLY_BREAKS_VECT_PEELED 
> (loop_vinfo));
>
>        /* Peel prolog and put it on preheader edge of loop.  */
> -      edge scalar_e = LOOP_VINFO_SCALAR_IV_EXIT (loop_vinfo);
> +      edge scalar_e = LOOP_VINFO_SCALAR_MAIN_EXIT (loop_vinfo);
>        edge prolog_e = NULL;
>        prolog = slpeel_tree_duplicate_loop_to_edge_cfg (loop, exit_e,
>                                                        scalar_loop, scalar_e,
> @@ -3462,7 +3462,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, 
> tree nitersm1,
>
>    if (epilog_peeling)
>      {
> -      e = LOOP_VINFO_IV_EXIT (loop_vinfo);
> +      e = LOOP_VINFO_MAIN_EXIT (loop_vinfo);
>        gcc_checking_assert (slpeel_can_duplicate_loop_p (loop, e, e));
>
>        /* Peel epilog and put it on exit edge of loop.  If we are vectorizing
> @@ -3472,7 +3472,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, 
> tree nitersm1,
>          If we are not vectorizing the epilog then we should use the scalar 
> loop
>          as the transformations mentioned above make less or no sense when not
>          vectorizing.  */
> -      edge scalar_e = LOOP_VINFO_SCALAR_IV_EXIT (loop_vinfo);
> +      edge scalar_e = LOOP_VINFO_SCALAR_MAIN_EXIT (loop_vinfo);
>        epilog = vect_epilogues ? get_loop_copy (loop) : scalar_loop;
>        edge epilog_e = vect_epilogues ? e : scalar_e;
>        edge new_epilog_e = NULL;
> @@ -3481,7 +3481,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, 
> tree nitersm1,
>         = slpeel_tree_duplicate_loop_to_edge_cfg (loop, e, epilog, epilog_e, 
> e,
>                                                   &new_epilog_e, true, &doms);
>
> -      LOOP_VINFO_EPILOGUE_IV_EXIT (loop_vinfo) = new_epilog_e;
> +      LOOP_VINFO_EPILOGUE_MAIN_EXIT (loop_vinfo) = new_epilog_e;
>        gcc_assert (epilog);
>        gcc_assert (new_epilog_e);
>        epilog->force_vectorize = false;
> @@ -3586,7 +3586,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, 
> tree nitersm1,
>          niters_vector_mult_vf steps.  */
>        gcc_checking_assert (vect_can_advance_ivs_p (loop_vinfo));
>        if (LOOP_VINFO_EARLY_BREAKS (loop_vinfo))
> -       update_e = single_succ_edge (LOOP_VINFO_IV_EXIT (loop_vinfo)->dest);
> +       update_e = single_succ_edge (LOOP_VINFO_MAIN_EXIT (loop_vinfo)->dest);
>
>        /* If we have a peeled vector iteration we will never skip the epilog 
> loop
>          and we can simplify the cfg a lot by not doing the edge split.  */
> @@ -3597,8 +3597,8 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, 
> tree nitersm1,
>           guard_cond = fold_build2 (EQ_EXPR, boolean_type_node,
>                                     niters, niters_vector_mult_vf);
>
> -         guard_bb = LOOP_VINFO_IV_EXIT (loop_vinfo)->dest;
> -         edge epilog_e = LOOP_VINFO_EPILOGUE_IV_EXIT (loop_vinfo);
> +         guard_bb = LOOP_VINFO_MAIN_EXIT (loop_vinfo)->dest;
> +         edge epilog_e = LOOP_VINFO_EPILOGUE_MAIN_EXIT (loop_vinfo);
>           guard_to = epilog_e->dest;
>           guard_e = slpeel_add_loop_guard (guard_bb, guard_cond, guard_to,
>                                            skip_vector ? anchor : guard_bb,
> @@ -3607,7 +3607,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, 
> tree nitersm1,
>           doms.safe_push (guard_to);
>           if (vect_epilogues)
>             epilogue_vinfo->skip_this_loop_edge = guard_e;
> -         edge main_iv = LOOP_VINFO_IV_EXIT (loop_vinfo);
> +         edge main_iv = LOOP_VINFO_MAIN_EXIT (loop_vinfo);
>           gphi_iterator gsi2 = gsi_start_phis (main_iv->dest);
>           for (gphi_iterator gsi = gsi_start_phis (guard_to);
>                !gsi_end_p (gsi); gsi_next (&gsi))
> @@ -3727,8 +3727,8 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, 
> tree nitersm1,
>      {
>        epilog->aux = epilogue_vinfo;
>        LOOP_VINFO_LOOP (epilogue_vinfo) = epilog;
> -      LOOP_VINFO_IV_EXIT (epilogue_vinfo)
> -       = LOOP_VINFO_EPILOGUE_IV_EXIT (loop_vinfo);
> +      LOOP_VINFO_MAIN_EXIT (epilogue_vinfo)
> +       = LOOP_VINFO_EPILOGUE_MAIN_EXIT (loop_vinfo);
>
>        loop_constraint_clear (epilog, LOOP_C_INFINITE);
>
> @@ -4364,7 +4364,7 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
>         currently using.  */
>        edge exit_edge;
>        if (loop_to_version == loop)
> -       exit_edge = LOOP_VINFO_IV_EXIT (loop_vinfo);
> +       exit_edge = LOOP_VINFO_MAIN_EXIT (loop_vinfo);
>        else
>         exit_edge = single_exit (loop_to_version);
>        exit_edge->dest->count = preheader->count;
> @@ -4458,7 +4458,7 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
>          currently using.  */
>        edge exit_edge;
>        if (loop_to_version == loop)
> -       exit_edge = LOOP_VINFO_IV_EXIT (loop_vinfo);
> +       exit_edge = LOOP_VINFO_MAIN_EXIT (loop_vinfo);
>        else
>         exit_edge = single_exit (loop_to_version);
>
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index 425810cb2f3..e535ba5cfa2 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -657,17 +657,24 @@ vec_init_loop_exit_info (class loop *loop)
>    /* Before we begin we must first determine which exit is the main one and
>       which are auxilary exits.  */
>    auto_vec<edge> exits = get_loop_exit_edges (loop);
> +  if (exits.length () == 0)
> +    return NULL;
>    if (exits.length () == 1)
>      return exits[0];
>
> -  /* If we have multiple exits we only support counting IV at the moment.
> +  /* If we have multiple exits, look for counting IV exit.
>       Analyze all exits and return the last one we can analyze.  */
>    class tree_niter_desc niter_desc;
>    edge candidate = NULL;
>    for (edge exit : exits)
>      {
>        if (!get_loop_exit_condition (exit))
> -       continue;
> +       {
> +         if (dump_enabled_p ())
> +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> +                            "Unhandled loop exit detected.\n");
> +         return NULL;
> +       }
>
>        if (number_of_iterations_exit_assumptions (loop, exit, &niter_desc, 
> NULL)
>           && !chrec_contains_undetermined (niter_desc.niter))
> @@ -688,6 +695,11 @@ vec_init_loop_exit_info (class loop *loop)
>         }
>      }
>
> +  /* If no exit is analyzable by scalar evolution, we return the last exit
> +     under the assummption we are dealing with an uncounted loop.  */
> +  if (!candidate && single_pred_p (loop->latch))
> +    candidate = loop_exits_from_bb_p (loop, single_pred (loop->latch));
> +
>    return candidate;
>  }
>
> @@ -759,9 +771,9 @@ _loop_vec_info::_loop_vec_info (class loop *loop_in, 
> vec_info_shared *shared)
>      orig_loop_info (NULL),
>      epilogue_vinfo (NULL),
>      drs_advanced_by (NULL_TREE),
> -    vec_loop_iv_exit (NULL),
> -    vec_epilogue_loop_iv_exit (NULL),
> -    scalar_loop_iv_exit (NULL)
> +    vec_loop_main_exit (NULL),
> +    vec_epilogue_loop_main_exit (NULL),
> +    scalar_loop_main_exit (NULL)
>  {
>    /* CHECKME: We want to visit all BBs before their successors (except for
>       latch blocks, for which this assertion wouldn't hold).  In the simple
> @@ -1426,8 +1438,7 @@ vect_analyze_loop_form (class loop *loop, gimple 
> *loop_vectorized_call,
>    if (!exit_e)
>      return opt_result::failure_at (vect_location,
>                                    "not vectorized:"
> -                                  " could not determine main exit from"
> -                                  " loop with multiple exits.\n");
> +                                  " Infinite loop detected.\n");
>    if (loop_vectorized_call)
>      {
>        tree arg = gimple_call_arg (loop_vectorized_call, 1);
> @@ -1681,7 +1692,7 @@ vect_create_loop_vinfo (class loop *loop, 
> vec_info_shared *shared,
>    for (; cond_id < info->conds.length (); cond_id ++)
>      LOOP_VINFO_LOOP_CONDS (loop_vinfo).safe_push (info->conds[cond_id]);
>
> -  LOOP_VINFO_IV_EXIT (loop_vinfo) = info->loop_exit;
> +  LOOP_VINFO_MAIN_EXIT (loop_vinfo) = info->loop_exit;
>
>    /* Check to see if we're vectorizing multiple exits.  */
>    LOOP_VINFO_EARLY_BREAKS (loop_vinfo)
> @@ -2502,8 +2513,8 @@ start_over:
>          dump_printf_loc (MSG_NOTE, vect_location, "epilog loop required\n");
>        if (!vect_can_advance_ivs_p (loop_vinfo)
>           || !slpeel_can_duplicate_loop_p (loop,
> -                                          LOOP_VINFO_IV_EXIT (loop_vinfo),
> -                                          LOOP_VINFO_IV_EXIT (loop_vinfo)))
> +                                          LOOP_VINFO_MAIN_EXIT (loop_vinfo),
> +                                          LOOP_VINFO_MAIN_EXIT (loop_vinfo)))
>          {
>           ok = opt_result::failure_at (vect_location,
>                                        "not vectorized: can't create required 
> "
> @@ -5416,7 +5427,7 @@ vect_create_epilog_for_reduction (loop_vec_info 
> loop_vinfo,
>        /* Create an induction variable.  */
>        gimple_stmt_iterator incr_gsi;
>        bool insert_after;
> -      vect_iv_increment_position (LOOP_VINFO_IV_EXIT (loop_vinfo),
> +      vect_iv_increment_position (LOOP_VINFO_MAIN_EXIT (loop_vinfo),
>                                   &incr_gsi, &insert_after);
>        create_iv (series_vect, PLUS_EXPR, vec_step, NULL_TREE, loop, 
> &incr_gsi,
>                  insert_after, &indx_before_incr, &indx_after_incr);
> @@ -5504,7 +5515,7 @@ vect_create_epilog_for_reduction (loop_vec_info 
> loop_vinfo,
>        def = vect_get_slp_vect_def (slp_node, i);
>        tree new_def = copy_ssa_name (def);
>        phi = create_phi_node (new_def, exit_bb);
> -      if (LOOP_VINFO_IV_EXIT (loop_vinfo) == loop_exit)
> +      if (LOOP_VINFO_MAIN_EXIT (loop_vinfo) == loop_exit)
>         SET_PHI_ARG_DEF (phi, loop_exit->dest_idx, def);
>        else
>         {
> @@ -10132,7 +10143,7 @@ vectorizable_live_operation (vec_info *vinfo, 
> stmt_vec_info stmt_info,
>           || !LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo))
>         vect_create_epilog_for_reduction (loop_vinfo, stmt_info, slp_node,
>                                           slp_node_instance,
> -                                         LOOP_VINFO_IV_EXIT (loop_vinfo));
> +                                         LOOP_VINFO_MAIN_EXIT (loop_vinfo));
>
>        /* If early break we only have to materialize the reduction on the 
> merge
>          block, but we have to find an alternate exit first.  */
> @@ -10141,7 +10152,7 @@ vectorizable_live_operation (vec_info *vinfo, 
> stmt_vec_info stmt_info,
>           slp_tree phis_node = slp_node_instance->reduc_phis;
>           stmt_info = SLP_TREE_REPRESENTATIVE (phis_node);
>           for (auto exit : get_loop_exit_edges (LOOP_VINFO_LOOP (loop_vinfo)))
> -           if (exit != LOOP_VINFO_IV_EXIT (loop_vinfo))
> +           if (exit != LOOP_VINFO_MAIN_EXIT (loop_vinfo))
>               {
>                 vect_create_epilog_for_reduction (loop_vinfo, stmt_info,
>                                                   phis_node, 
> slp_node_instance,
> @@ -10151,7 +10162,7 @@ vectorizable_live_operation (vec_info *vinfo, 
> stmt_vec_info stmt_info,
>           if (LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo))
>             vect_create_epilog_for_reduction (loop_vinfo, stmt_info,
>                                               phis_node, slp_node_instance,
> -                                             LOOP_VINFO_IV_EXIT 
> (loop_vinfo));
> +                                             LOOP_VINFO_MAIN_EXIT 
> (loop_vinfo));
>         }
>
>        return true;
> @@ -10290,7 +10301,7 @@ vectorizable_live_operation (vec_info *vinfo, 
> stmt_vec_info stmt_info,
>          in these cases for an early break we restart the iteration the 
> vector code
>          did.  For the live values we want the value at the start of the 
> iteration
>          rather than at the end.  */
> -      edge main_e = LOOP_VINFO_IV_EXIT (loop_vinfo);
> +      edge main_e = LOOP_VINFO_MAIN_EXIT (loop_vinfo);
>        bool all_exits_as_early_p = LOOP_VINFO_EARLY_BREAKS_VECT_PEELED 
> (loop_vinfo);
>        FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, lhs)
>         if (!is_gimple_debug (use_stmt)
> @@ -11040,7 +11051,7 @@ vect_update_ivs_after_vectorizer_for_early_breaks 
> (loop_vec_info loop_vinfo)
>        basic_block exit_bb = NULL;
>        /* Identify the early exit merge block.  I wish we had stored this.  */
>        for (auto e : get_loop_exit_edges (loop))
> -       if (e != LOOP_VINFO_IV_EXIT (loop_vinfo))
> +       if (e != LOOP_VINFO_MAIN_EXIT (loop_vinfo))
>           {
>             exit_bb = e->dest;
>             break;
> @@ -11106,7 +11117,7 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple 
> *loop_vectorized_call)
>
>    /* Make sure there exists a single-predecessor exit bb.  Do this before
>       versioning.   */
> -  edge e = LOOP_VINFO_IV_EXIT (loop_vinfo);
> +  edge e = LOOP_VINFO_MAIN_EXIT (loop_vinfo);
>    if (! single_pred_p (e->dest) && !LOOP_VINFO_EARLY_BREAKS (loop_vinfo))
>      {
>        split_loop_exit_edge (e, true);
> @@ -11132,7 +11143,7 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple 
> *loop_vectorized_call)
>       loop closed PHI nodes on the exit.  */
>    if (LOOP_VINFO_SCALAR_LOOP (loop_vinfo))
>      {
> -      e = LOOP_VINFO_SCALAR_IV_EXIT (loop_vinfo);
> +      e = LOOP_VINFO_SCALAR_MAIN_EXIT (loop_vinfo);
>        if (! single_pred_p (e->dest))
>         {
>           split_loop_exit_edge (e, true);
> @@ -11164,7 +11175,7 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple 
> *loop_vectorized_call)
>               (LOOP_VINFO_SCALAR_LOOP_SCALING (loop_vinfo));
>        scale_loop_frequencies (LOOP_VINFO_SCALAR_LOOP (loop_vinfo),
>                               LOOP_VINFO_SCALAR_LOOP_SCALING (loop_vinfo));
> -      LOOP_VINFO_SCALAR_IV_EXIT (loop_vinfo)->dest->count = preheader->count;
> +      LOOP_VINFO_SCALAR_MAIN_EXIT (loop_vinfo)->dest->count = 
> preheader->count;
>      }
>
>    if (niters_vector == NULL_TREE)
> @@ -11297,7 +11308,7 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple 
> *loop_vectorized_call)
>       a zero NITERS becomes a nonzero NITERS_VECTOR.  */
>    if (integer_onep (step_vector))
>      niters_no_overflow = true;
> -  vect_set_loop_condition (loop, LOOP_VINFO_IV_EXIT (loop_vinfo), loop_vinfo,
> +  vect_set_loop_condition (loop, LOOP_VINFO_MAIN_EXIT (loop_vinfo), 
> loop_vinfo,
>                            niters_vector, step_vector, niters_vector_mult_vf,
>                            !niters_no_overflow);
>
> @@ -11376,7 +11387,7 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple 
> *loop_vectorized_call)
>                           assumed_vf) - 1
>          : wi::udiv_floor (loop->nb_iterations_estimate + bias_for_assumed,
>                            assumed_vf) - 1);
> -  scale_profile_for_vect_loop (loop, LOOP_VINFO_IV_EXIT (loop_vinfo),
> +  scale_profile_for_vect_loop (loop, LOOP_VINFO_MAIN_EXIT (loop_vinfo),
>                                assumed_vf, flat);
>
>    if (dump_enabled_p ())
> diff --git a/gcc/tree-vectorizer.cc b/gcc/tree-vectorizer.cc
> index e7a3f265048..938d9bdc762 100644
> --- a/gcc/tree-vectorizer.cc
> +++ b/gcc/tree-vectorizer.cc
> @@ -965,7 +965,7 @@ set_uid_loop_bbs (loop_vec_info loop_vinfo, gimple 
> *loop_vectorized_call,
>    class loop *scalar_loop = get_loop (fun, tree_to_shwi (arg));
>
>    LOOP_VINFO_SCALAR_LOOP (loop_vinfo) = scalar_loop;
> -  LOOP_VINFO_SCALAR_IV_EXIT (loop_vinfo)
> +  LOOP_VINFO_SCALAR_MAIN_EXIT (loop_vinfo)
>      = vec_init_loop_exit_info (scalar_loop);
>    gcc_checking_assert (vect_loop_vectorized_call (scalar_loop)
>                        == loop_vectorized_call);
> diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
> index 1628ccb3031..679c5428f67 100644
> --- a/gcc/tree-vectorizer.h
> +++ b/gcc/tree-vectorizer.h
> @@ -1219,17 +1219,17 @@ public:
>    /* If this is an epilogue loop the DR advancement applied.  */
>    tree drs_advanced_by;
>
> -  /* The controlling loop IV for the current loop when vectorizing.  This IV
> -     controls the natural exits of the loop.  */
> -  edge vec_loop_iv_exit;
> +  /* The controlling loop exit for the current loop when vectorizing.
> +     For counted loops, this IV controls the natural exits of the loop.  */
> +  edge vec_loop_main_exit;
>
> -  /* The controlling loop IV for the epilogue loop when vectorizing.  This IV
> -     controls the natural exits of the loop.  */
> -  edge vec_epilogue_loop_iv_exit;
> +  /* The controlling loop exit for the epilogue loop when vectorizing.
> +     For counted loops, this IV controls the natural exits of the loop.  */
> +  edge vec_epilogue_loop_main_exit;
>
> -  /* The controlling loop IV for the scalar loop being vectorized.  This IV
> -     controls the natural exits of the loop.  */
> -  edge scalar_loop_iv_exit;
> +  /* The controlling loop exit for the scalar loop being vectorized.
> +     For counted loops, this IV controls the natural exits of the loop.  */
> +  edge scalar_loop_main_exit;
>
>    /* Used to store the list of stores needing to be moved if doing early
>       break vectorization as they would violate the scalar loop semantics if
> @@ -1256,9 +1256,9 @@ public:
>
>  /* Access Functions.  */
>  #define LOOP_VINFO_LOOP(L)                 (L)->loop
> -#define LOOP_VINFO_IV_EXIT(L)              (L)->vec_loop_iv_exit
> -#define LOOP_VINFO_EPILOGUE_IV_EXIT(L)     (L)->vec_epilogue_loop_iv_exit
> -#define LOOP_VINFO_SCALAR_IV_EXIT(L)       (L)->scalar_loop_iv_exit
> +#define LOOP_VINFO_MAIN_EXIT(L)              (L)->vec_loop_main_exit
> +#define LOOP_VINFO_EPILOGUE_MAIN_EXIT(L)     (L)->vec_epilogue_loop_main_exit
> +#define LOOP_VINFO_SCALAR_MAIN_EXIT(L)       (L)->scalar_loop_main_exit
>  #define LOOP_VINFO_BBS(L)                  (L)->bbs
>  #define LOOP_VINFO_NBBS(L)                 (L)->nbbs
>  #define LOOP_VINFO_NITERSM1(L)             (L)->num_itersm1
> @@ -1313,7 +1313,7 @@ public:
>  #define LOOP_VINFO_EARLY_BREAKS(L)         (L)->early_breaks
>  #define LOOP_VINFO_EARLY_BRK_STORES(L)     (L)->early_break_stores
>  #define LOOP_VINFO_EARLY_BREAKS_VECT_PEELED(L)  \
> -  ((single_pred ((L)->loop->latch) != (L)->vec_loop_iv_exit->src) \
> +  ((single_pred ((L)->loop->latch) != (L)->vec_loop_main_exit->src) \
>     || LOOP_VINFO_NITERS_UNCOUNTED_P (L))
>  #define LOOP_VINFO_EARLY_BREAKS_LIVE_IVS(L)  \
>    (L)->early_break_live_ivs
> --
> 2.43.0
>

Reply via email to