public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>, richard.sandiford@arm.com
Subject: Re: [36/46] Add a pattern_stmt_p field to stmt_vec_info
Date: Wed, 25 Jul 2018 10:15:00 -0000	[thread overview]
Message-ID: <CAFiYyc23rzC4WGaf_SDVBnWQi_VRj1pe=30B9W5n1-2k9PqFOg@mail.gmail.com> (raw)
In-Reply-To: <87lga1lzfz.fsf@arm.com>

On Tue, Jul 24, 2018 at 12:07 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> This patch adds a pattern_stmt_p field to stmt_vec_info, so that it's
> possible to tell whether the statement is a pattern statement without
> referring to other statements.  The new field goes in what was
> previously a hole in the structure, so the size is the same as before.

Not sure what the advantage is?  is_pattern_stmt_p () looks nicer
than ->is_pattern_p

>
> 2018-07-24  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * tree-vectorizer.h (_stmt_vec_info::pattern_stmt_p): New field.
>         (is_pattern_stmt_p): Delete.
>         * tree-vect-patterns.c (vect_init_pattern_stmt): Set pattern_stmt_p
>         on pattern statements.
>         (vect_split_statement, vect_mark_pattern_stmts): Use the new
>         pattern_stmt_p field instead of is_pattern_stmt_p.
>         * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Likewise.
>         * tree-vect-loop.c (vectorizable_live_operation): Likewise.
>         * tree-vect-slp.c (vect_build_slp_tree_2): Likewise.
>         (vect_find_last_scalar_stmt_in_slp, vect_remove_slp_scalar_calls)
>         (vect_schedule_slp): Likewise.
>         * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise.
>         (vectorizable_call, vectorizable_simd_clone_call, vectorizable_shift)
>         (vectorizable_store, vect_remove_stores): Likewise.
>
> Index: gcc/tree-vectorizer.h
> ===================================================================
> --- gcc/tree-vectorizer.h       2018-07-24 10:23:56.440544995 +0100
> +++ gcc/tree-vectorizer.h       2018-07-24 10:24:02.364492386 +0100
> @@ -791,6 +791,12 @@ struct _stmt_vec_info {
>    /* Stmt is part of some pattern (computation idiom)  */
>    bool in_pattern_p;
>
> +  /* True if the statement was created during pattern recognition as
> +     part of the replacement for RELATED_STMT.  This implies that the
> +     statement isn't part of any basic block, although for convenience
> +     its gimple_bb is the same as for RELATED_STMT.  */
> +  bool pattern_stmt_p;
> +
>    /* Is this statement vectorizable or should it be skipped in (partial)
>       vectorization.  */
>    bool vectorizable;
> @@ -1151,16 +1157,6 @@ get_later_stmt (stmt_vec_info stmt1_info
>      return stmt2_info;
>  }
>
> -/* Return TRUE if a statement represented by STMT_INFO is a part of a
> -   pattern.  */
> -
> -static inline bool
> -is_pattern_stmt_p (stmt_vec_info stmt_info)
> -{
> -  stmt_vec_info related_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info);
> -  return related_stmt_info && STMT_VINFO_IN_PATTERN_P (related_stmt_info);
> -}
> -
>  /* Return true if BB is a loop header.  */
>
>  static inline bool
> Index: gcc/tree-vect-patterns.c
> ===================================================================
> --- gcc/tree-vect-patterns.c    2018-07-24 10:23:59.408518638 +0100
> +++ gcc/tree-vect-patterns.c    2018-07-24 10:24:02.360492422 +0100
> @@ -108,6 +108,7 @@ vect_init_pattern_stmt (gimple *pattern_
>      pattern_stmt_info = orig_stmt_info->vinfo->add_stmt (pattern_stmt);
>    gimple_set_bb (pattern_stmt, gimple_bb (orig_stmt_info->stmt));
>
> +  pattern_stmt_info->pattern_stmt_p = true;
>    STMT_VINFO_RELATED_STMT (pattern_stmt_info) = orig_stmt_info;
>    STMT_VINFO_DEF_TYPE (pattern_stmt_info)
>      = STMT_VINFO_DEF_TYPE (orig_stmt_info);
> @@ -630,7 +631,7 @@ vect_recog_temp_ssa_var (tree type, gimp
>  vect_split_statement (stmt_vec_info stmt2_info, tree new_rhs,
>                       gimple *stmt1, tree vectype)
>  {
> -  if (is_pattern_stmt_p (stmt2_info))
> +  if (stmt2_info->pattern_stmt_p)
>      {
>        /* STMT2_INFO is part of a pattern.  Get the statement to which
>          the pattern is attached.  */
> @@ -4726,7 +4727,7 @@ vect_mark_pattern_stmts (stmt_vec_info o
>    gimple *def_seq = STMT_VINFO_PATTERN_DEF_SEQ (orig_stmt_info);
>
>    gimple *orig_pattern_stmt = NULL;
> -  if (is_pattern_stmt_p (orig_stmt_info))
> +  if (orig_stmt_info->pattern_stmt_p)
>      {
>        /* We're replacing a statement in an existing pattern definition
>          sequence.  */
> Index: gcc/tree-vect-data-refs.c
> ===================================================================
> --- gcc/tree-vect-data-refs.c   2018-07-24 10:23:53.204573732 +0100
> +++ gcc/tree-vect-data-refs.c   2018-07-24 10:24:02.356492457 +0100
> @@ -212,9 +212,9 @@ vect_preserves_scalar_order_p (stmt_vec_
>       (but could happen later) while reads will happen no later than their
>       current position (but could happen earlier).  Reordering is therefore
>       only possible if the first access is a write.  */
> -  if (is_pattern_stmt_p (stmtinfo_a))
> +  if (stmtinfo_a->pattern_stmt_p)
>      stmtinfo_a = STMT_VINFO_RELATED_STMT (stmtinfo_a);
> -  if (is_pattern_stmt_p (stmtinfo_b))
> +  if (stmtinfo_b->pattern_stmt_p)
>      stmtinfo_b = STMT_VINFO_RELATED_STMT (stmtinfo_b);
>    stmt_vec_info earlier_stmt_info = get_earlier_stmt (stmtinfo_a, stmtinfo_b);
>    return !DR_IS_WRITE (STMT_VINFO_DATA_REF (earlier_stmt_info));
> Index: gcc/tree-vect-loop.c
> ===================================================================
> --- gcc/tree-vect-loop.c        2018-07-24 10:23:56.436545030 +0100
> +++ gcc/tree-vect-loop.c        2018-07-24 10:24:02.360492422 +0100
> @@ -7907,7 +7907,7 @@ vectorizable_live_operation (stmt_vec_in
>      }
>
>    /* If stmt has a related stmt, then use that for getting the lhs.  */
> -  gimple *stmt = (is_pattern_stmt_p (stmt_info)
> +  gimple *stmt = (stmt_info->pattern_stmt_p
>                   ? STMT_VINFO_RELATED_STMT (stmt_info)->stmt
>                   : stmt_info->stmt);
>
> Index: gcc/tree-vect-slp.c
> ===================================================================
> --- gcc/tree-vect-slp.c 2018-07-24 10:23:53.204573732 +0100
> +++ gcc/tree-vect-slp.c 2018-07-24 10:24:02.360492422 +0100
> @@ -376,7 +376,7 @@ vect_get_and_check_slp_defs (vec_info *v
>        /* Check if DEF_STMT_INFO is a part of a pattern in LOOP and get
>          the def stmt from the pattern.  Check that all the stmts of the
>          node are in the pattern.  */
> -      if (def_stmt_info && is_pattern_stmt_p (def_stmt_info))
> +      if (def_stmt_info && def_stmt_info->pattern_stmt_p)
>          {
>            pattern = true;
>            if (!first && !oprnd_info->first_pattern
> @@ -1315,7 +1315,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
>               /* ???  Rejecting patterns this way doesn't work.  We'd have to
>                  do extra work to cancel the pattern so the uses see the
>                  scalar version.  */
> -             && !is_pattern_stmt_p (SLP_TREE_SCALAR_STMTS (child)[0]))
> +             && !SLP_TREE_SCALAR_STMTS (child)[0]->pattern_stmt_p)
>             {
>               slp_tree grandchild;
>
> @@ -1359,7 +1359,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
>           /* ???  Rejecting patterns this way doesn't work.  We'd have to
>              do extra work to cancel the pattern so the uses see the
>              scalar version.  */
> -         && !is_pattern_stmt_p (stmt_info))
> +         && !stmt_info->pattern_stmt_p)
>         {
>           dump_printf_loc (MSG_NOTE, vect_location,
>                            "Building vector operands from scalars\n");
> @@ -1486,7 +1486,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
>                   /* ???  Rejecting patterns this way doesn't work.  We'd have
>                      to do extra work to cancel the pattern so the uses see the
>                      scalar version.  */
> -                 && !is_pattern_stmt_p (SLP_TREE_SCALAR_STMTS (child)[0]))
> +                 && !SLP_TREE_SCALAR_STMTS (child)[0]->pattern_stmt_p)
>                 {
>                   unsigned int j;
>                   slp_tree grandchild;
> @@ -1848,7 +1848,7 @@ vect_find_last_scalar_stmt_in_slp (slp_t
>
>    for (int i = 0; SLP_TREE_SCALAR_STMTS (node).iterate (i, &stmt_vinfo); i++)
>      {
> -      if (is_pattern_stmt_p (stmt_vinfo))
> +      if (stmt_vinfo->pattern_stmt_p)
>         stmt_vinfo = STMT_VINFO_RELATED_STMT (stmt_vinfo);
>        last = last ? get_later_stmt (stmt_vinfo, last) : stmt_vinfo;
>      }
> @@ -4044,8 +4044,7 @@ vect_remove_slp_scalar_calls (slp_tree n
>        gcall *stmt = dyn_cast <gcall *> (stmt_info->stmt);
>        if (!stmt || gimple_bb (stmt) == NULL)
>         continue;
> -      if (is_pattern_stmt_p (stmt_info)
> -         || !PURE_SLP_STMT (stmt_info))
> +      if (stmt_info->pattern_stmt_p || !PURE_SLP_STMT (stmt_info))
>         continue;
>        lhs = gimple_call_lhs (stmt);
>        new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs)));
> @@ -4106,7 +4105,7 @@ vect_schedule_slp (vec_info *vinfo)
>           if (!STMT_VINFO_DATA_REF (store_info))
>             break;
>
> -         if (is_pattern_stmt_p (store_info))
> +         if (store_info->pattern_stmt_p)
>             store_info = STMT_VINFO_RELATED_STMT (store_info);
>           /* Free the attached stmt_vec_info and remove the stmt.  */
>           gsi = gsi_for_stmt (store_info);
> Index: gcc/tree-vect-stmts.c
> ===================================================================
> --- gcc/tree-vect-stmts.c       2018-07-24 10:23:56.440544995 +0100
> +++ gcc/tree-vect-stmts.c       2018-07-24 10:24:02.364492386 +0100
> @@ -731,7 +731,7 @@ vect_mark_stmts_to_be_vectorized (loop_v
>              break;
>          }
>
> -      if (is_pattern_stmt_p (stmt_vinfo))
> +      if (stmt_vinfo->pattern_stmt_p)
>          {
>            /* Pattern statements are not inserted into the code, so
>               FOR_EACH_PHI_OR_STMT_USE optimizes their operands out, and we
> @@ -3623,7 +3623,7 @@ vectorizable_call (stmt_vec_info stmt_in
>    if (slp_node)
>      return true;
>
> -  if (is_pattern_stmt_p (stmt_info))
> +  if (stmt_info->pattern_stmt_p)
>      stmt_info = STMT_VINFO_RELATED_STMT (stmt_info);
>    lhs = gimple_get_lhs (stmt_info->stmt);
>
> @@ -4362,7 +4362,7 @@ vectorizable_simd_clone_call (stmt_vec_i
>    if (scalar_dest)
>      {
>        type = TREE_TYPE (scalar_dest);
> -      if (is_pattern_stmt_p (stmt_info))
> +      if (stmt_info->pattern_stmt_p)
>         lhs = gimple_call_lhs (STMT_VINFO_RELATED_STMT (stmt_info)->stmt);
>        else
>         lhs = gimple_call_lhs (stmt);
> @@ -5552,7 +5552,7 @@ vectorizable_shift (stmt_vec_info stmt_i
>        /* If the shift amount is computed by a pattern stmt we cannot
>           use the scalar amount directly thus give up and use a vector
>          shift.  */
> -      if (op1_def_stmt_info && is_pattern_stmt_p (op1_def_stmt_info))
> +      if (op1_def_stmt_info && op1_def_stmt_info->pattern_stmt_p)
>         scalar_shift_arg = false;
>      }
>    else
> @@ -6286,7 +6286,7 @@ vectorizable_store (stmt_vec_info stmt_i
>      {
>        tree scalar_dest = gimple_assign_lhs (assign);
>        if (TREE_CODE (scalar_dest) == VIEW_CONVERT_EXPR
> -         && is_pattern_stmt_p (stmt_info))
> +         && stmt_info->pattern_stmt_p)
>         scalar_dest = TREE_OPERAND (scalar_dest, 0);
>        if (TREE_CODE (scalar_dest) != ARRAY_REF
>           && TREE_CODE (scalar_dest) != BIT_FIELD_REF
> @@ -9839,7 +9839,7 @@ vect_remove_stores (stmt_vec_info first_
>    while (next_stmt_info)
>      {
>        stmt_vec_info tmp = DR_GROUP_NEXT_ELEMENT (next_stmt_info);
> -      if (is_pattern_stmt_p (next_stmt_info))
> +      if (next_stmt_info->pattern_stmt_p)
>         next_stmt_info = STMT_VINFO_RELATED_STMT (next_stmt_info);
>        /* Free the attached stmt_vec_info and remove the stmt.  */
>        next_si = gsi_for_stmt (next_stmt_info->stmt);

  reply	other threads:[~2018-07-25 10:15 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-24  9:52 [00/46] Remove vinfo_for_stmt etc Richard Sandiford
2018-07-24  9:52 ` [01/46] Move special cases out of get_initial_def_for_reduction Richard Sandiford
2018-07-25  8:42   ` Richard Biener
2018-07-24  9:53 ` [03/46] Remove unnecessary update of NUM_SLP_USES Richard Sandiford
2018-07-25  8:46   ` Richard Biener
2018-07-24  9:53 ` [02/46] Remove dead vectorizable_reduction code Richard Sandiford
2018-07-25  8:43   ` Richard Biener
2018-07-24  9:54 ` [05/46] Fix make_ssa_name call in vectorizable_reduction Richard Sandiford
2018-07-25  8:47   ` Richard Biener
2018-07-24  9:54 ` [04/46] Factor out the test for a valid reduction input Richard Sandiford
2018-07-25  8:46   ` Richard Biener
2018-07-24  9:55 ` [07/46] Add vec_info::lookup_stmt Richard Sandiford
2018-07-25  9:11   ` Richard Biener
2018-07-24  9:55 ` [08/46] Add vec_info::lookup_def Richard Sandiford
2018-07-25  9:12   ` Richard Biener
2018-07-24  9:55 ` [06/46] Add vec_info::add_stmt Richard Sandiford
2018-07-25  9:10   ` Richard Biener
2018-07-24  9:56 ` [09/46] Add vec_info::lookup_single_use Richard Sandiford
2018-07-25  9:13   ` Richard Biener
2018-07-24  9:57 ` [11/46] Pass back a stmt_vec_info from vect_is_simple_use Richard Sandiford
2018-07-25  9:18   ` Richard Biener
2018-07-24  9:57 ` [10/46] Temporarily make stmt_vec_info a class Richard Sandiford
2018-07-25  9:14   ` Richard Biener
2018-07-24  9:58 ` [12/46] Make vect_finish_stmt_generation return a stmt_vec_info Richard Sandiford
2018-07-25  9:19   ` Richard Biener
2018-07-24  9:58 ` [13/46] Make STMT_VINFO_RELATED_STMT " Richard Sandiford
2018-07-25  9:19   ` Richard Biener
2018-07-24  9:58 ` [14/46] Make STMT_VINFO_VEC_STMT " Richard Sandiford
2018-07-25  9:21   ` Richard Biener
2018-07-25 11:03     ` Richard Sandiford
2018-08-02  0:22   ` H.J. Lu
2018-08-02  9:58     ` Richard Sandiford
2018-07-24  9:59 ` [17/46] Make LOOP_VINFO_REDUCTIONS an auto_vec<stmt_vec_info> Richard Sandiford
2018-07-25  9:23   ` Richard Biener
2018-07-24  9:59 ` [16/46] Make STMT_VINFO_REDUC_DEF a stmt_vec_info Richard Sandiford
2018-07-25  9:22   ` Richard Biener
2018-07-24  9:59 ` [15/46] Make SLP_TREE_VEC_STMTS a vec<stmt_vec_info> Richard Sandiford
2018-07-25  9:22   ` Richard Biener
2018-07-24 10:00 ` [18/46] Make SLP_TREE_SCALAR_STMTS " Richard Sandiford
2018-07-25  9:27   ` Richard Biener
2018-07-31 15:03     ` Richard Sandiford
2018-07-24 10:01 ` [19/46] Make vect_dr_stmt return a stmt_vec_info Richard Sandiford
2018-07-25  9:28   ` Richard Biener
2018-07-24 10:01 ` [20/46] Make *FIRST_ELEMENT and *NEXT_ELEMENT stmt_vec_infos Richard Sandiford
2018-07-25  9:28   ` Richard Biener
2018-07-24 10:01 ` [21/46] Make grouped_stores and reduction_chains use stmt_vec_infos Richard Sandiford
2018-07-25  9:28   ` Richard Biener
2018-07-24 10:02 ` [22/46] Make DR_GROUP_SAME_DR_STMT a stmt_vec_info Richard Sandiford
2018-07-25  9:29   ` Richard Biener
2018-07-24 10:02 ` [24/46] Make stmt_info_for_cost use " Richard Sandiford
2018-07-25  9:30   ` Richard Biener
2018-07-24 10:02 ` [23/46] Make LOOP_VINFO_MAY_MISALIGN_STMTS use stmt_vec_info Richard Sandiford
2018-07-25  9:29   ` Richard Biener
2018-07-24 10:03 ` [25/46] Make get_earlier/later_stmt take and return stmt_vec_infos Richard Sandiford
2018-07-25  9:31   ` Richard Biener
2018-07-24 10:03 ` [26/46] Make more use of dyn_cast in tree-vect* Richard Sandiford
2018-07-25  9:31   ` Richard Biener
2018-07-24 10:03 ` [27/46] Remove duplicated stmt_vec_info lookups Richard Sandiford
2018-07-25  9:32   ` Richard Biener
2018-07-24 10:04 ` [29/46] Use stmt_vec_info instead of gimple stmts internally (part 2) Richard Sandiford
2018-07-25 10:03   ` Richard Biener
2018-07-24 10:04 ` [30/46] Use stmt_vec_infos rather than gimple stmts for worklists Richard Sandiford
2018-07-25 10:04   ` Richard Biener
2018-07-24 10:04 ` [28/46] Use stmt_vec_info instead of gimple stmts internally (part 1) Richard Sandiford
2018-07-25  9:33   ` Richard Biener
2018-07-24 10:05 ` [32/46] Use stmt_vec_info in function interfaces (part 2) Richard Sandiford
2018-07-25 10:06   ` Richard Biener
2018-07-24 10:05 ` [31/46] Use stmt_vec_info in function interfaces (part 1) Richard Sandiford
2018-07-25 10:05   ` Richard Biener
2018-07-24 10:06 ` [34/46] Alter interface to vect_get_vec_def_for_stmt_copy Richard Sandiford
2018-07-25 10:13   ` Richard Biener
2018-07-24 10:06 ` [35/46] Alter interfaces within vect_pattern_recog Richard Sandiford
2018-07-25 10:14   ` Richard Biener
2018-07-24 10:06 ` [33/46] Use stmt_vec_infos instead of vec_info/gimple stmt pairs Richard Sandiford
2018-07-25 10:06   ` Richard Biener
2018-07-24 10:07 ` [36/46] Add a pattern_stmt_p field to stmt_vec_info Richard Sandiford
2018-07-25 10:15   ` Richard Biener [this message]
2018-07-25 11:09     ` Richard Sandiford
2018-07-25 11:48       ` Richard Biener
2018-07-26 10:29         ` Richard Sandiford
2018-07-26 11:15           ` Richard Biener
2018-07-24 10:07 ` [37/46] Associate alignment information with stmt_vec_infos Richard Sandiford
2018-07-25 10:18   ` Richard Biener
2018-07-26 10:55     ` Richard Sandiford
2018-07-26 11:13       ` Richard Biener
2018-07-24 10:08 ` [38/46] Pass stmt_vec_infos instead of data_references where relevant Richard Sandiford
2018-07-25 10:21   ` Richard Biener
2018-07-25 11:21     ` Richard Sandiford
2018-07-26 11:05       ` Richard Sandiford
2018-07-26 11:13         ` Richard Biener
2018-07-24 10:08 ` [39/46] Replace STMT_VINFO_UNALIGNED_DR with the associated statement Richard Sandiford
2018-07-26 11:08   ` [39/46 v2] Change STMT_VINFO_UNALIGNED_DR to a dr_vec_info Richard Sandiford
2018-07-26 11:13     ` Richard Biener
2018-07-24 10:09 ` [40/46] Add vec_info::lookup_dr Richard Sandiford
2018-07-26 11:10   ` [40/46 v2] " Richard Sandiford
2018-07-26 11:16     ` Richard Biener
2018-07-24 10:09 ` [41/46] Add vec_info::remove_stmt Richard Sandiford
2018-07-31 12:02   ` Richard Biener
2018-07-24 10:09 ` [42/46] Add vec_info::replace_stmt Richard Sandiford
2018-07-31 12:03   ` Richard Biener
2018-07-24 10:10 ` [45/46] Remove vect_stmt_in_region_p Richard Sandiford
2018-07-31 12:06   ` Richard Biener
2018-07-24 10:10 ` [43/46] Make free_stmt_vec_info take a stmt_vec_info Richard Sandiford
2018-07-31 12:03   ` Richard Biener
2018-07-24 10:10 ` [44/46] Remove global vinfo_for_stmt-related routines Richard Sandiford
2018-07-31 12:05   ` Richard Biener
2018-07-24 10:11 ` [46/46] Turn stmt_vec_info back into a typedef Richard Sandiford
2018-07-31 12:07   ` Richard Biener

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='CAFiYyc23rzC4WGaf_SDVBnWQi_VRj1pe=30B9W5n1-2k9PqFOg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.sandiford@arm.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).