On Thu, Aug 8, 2024 at 12:11 AM Andrew Pinski <quic_apin...@quicinc.com> wrote:
>
> This is a small C++11-ificiation for the use of vect_vect_recog_func_ptrs.
> Changes the loop into a range based loop which then we can remove the variable
> definition of NUM_PATTERNS. Also uses const reference instead of a pointer.
>
> Bootstrapped and tested on x86_64-linux-gnu.

OK

> gcc/ChangeLog:
>
>         * tree-vect-patterns.cc (NUM_PATTERNS): Delete.
>         (vect_pattern_recog_1): Constify and change
>         recog_func to a reference.
>         (vect_pattern_recog): Use range-based loop over
>         vect_vect_recog_func_ptrs.
>
> Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>
> ---
>  gcc/tree-vect-patterns.cc | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
> index 87b3dc413b8..f52de2b6972 100644
> --- a/gcc/tree-vect-patterns.cc
> +++ b/gcc/tree-vect-patterns.cc
> @@ -7362,8 +7362,6 @@ static vect_recog_func vect_vect_recog_func_ptrs[] = {
>    /* These must come after the double widening ones.  */
>  };
>
> -const unsigned int NUM_PATTERNS = ARRAY_SIZE (vect_vect_recog_func_ptrs);
> -
>  /* Mark statements that are involved in a pattern.  */
>
>  void
> @@ -7518,7 +7516,7 @@ vect_mark_pattern_stmts (vec_info *vinfo,
>
>  static void
>  vect_pattern_recog_1 (vec_info *vinfo,
> -                     vect_recog_func *recog_func, stmt_vec_info stmt_info)
> +                     const vect_recog_func &recog_func, stmt_vec_info 
> stmt_info)
>  {
>    gimple *pattern_stmt;
>    tree pattern_vectype;
> @@ -7538,7 +7536,7 @@ vect_pattern_recog_1 (vec_info *vinfo,
>      }
>
>    gcc_assert (!STMT_VINFO_PATTERN_DEF_SEQ (stmt_info));
> -  pattern_stmt = recog_func->fn (vinfo, stmt_info, &pattern_vectype);
> +  pattern_stmt = recog_func.fn (vinfo, stmt_info, &pattern_vectype);
>    if (!pattern_stmt)
>      {
>        /* Clear any half-formed pattern definition sequence.  */
> @@ -7550,7 +7548,7 @@ vect_pattern_recog_1 (vec_info *vinfo,
>    if (dump_enabled_p ())
>      dump_printf_loc (MSG_NOTE, vect_location,
>                      "%s pattern recognized: %G",
> -                    recog_func->name, pattern_stmt);
> +                    recog_func.name, pattern_stmt);
>
>    /* Mark the stmts that are involved in the pattern. */
>    vect_mark_pattern_stmts (vinfo, stmt_info, pattern_stmt, pattern_vectype);
> @@ -7658,8 +7656,8 @@ vect_pattern_recog (vec_info *vinfo)
>             continue;
>
>           /* Scan over all generic vect_recog_xxx_pattern functions.  */
> -         for (unsigned j = 0; j < NUM_PATTERNS; j++)
> -           vect_pattern_recog_1 (vinfo, &vect_vect_recog_func_ptrs[j],
> +         for (const auto &func_ptr : vect_vect_recog_func_ptrs)
> +           vect_pattern_recog_1 (vinfo, func_ptr,
>                                   stmt_info);
>         }
>      }
> --
> 2.43.0
>

Reply via email to