public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Richard Sandiford <richard.sandiford@arm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [13/n] Allow mixed vector sizes within a single vectorised stmt
Date: Tue, 05 Nov 2019 12:58:00 -0000	[thread overview]
Message-ID: <CAFiYyc3ptxqKYYQnDhO1J2AOcjKp2bF35nhhKKHAvR2XVqPFBg@mail.gmail.com> (raw)
In-Reply-To: <mptpnil7zxt.fsf@arm.com>

On Fri, Oct 25, 2019 at 2:49 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> Although a previous patch allowed mixed vector sizes within a vector
> region, we generally still required equal vector sizes within a vector
> stmt.  Specifically, vect_get_vector_types_for_stmt computes two vector
> types: the vector type corresponding to STMT_VINFO_VECTYPE and the
> vector type that determines the minimum vectorisation factor for the
> stmt ("nunits_vectype").  It then required these two types to be
> the same size.
>
> There doesn't seem to be any need for that restriction though.  AFAICT,
> all vectorizable_* functions either do their own compatibility checks
> or don't need to do them (because gimple guarantees that the scalar
> types are compatible).
>
> It should always be the case that nunits_vectype has at least as many
> elements as the other vectype, but that's something we can assert for.
>
> I couldn't resist a couple of other tweaks while there:
>
> - there's no need to compute nunits_vectype if its element type is
>   the same as STMT_VINFO_VECTYPE's.
>
> - it's useful to distinguish the nunits_vectype from the main vectype
>   in dump messages
>
> - when reusing the existing STMT_VINFO_VECTYPE, it's useful to say so
>   in the dump, and say what the type is

OK.

Thanks,
Richard.

>
> 2019-10-24  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * tree-vect-stmts.c (vect_get_vector_types_for_stmt): Don't
>         require vectype and nunits_vectype to have the same size;
>         instead assert that nunits_vectype has at least as many
>         elements as vectype.  Don't compute a separate nunits_vectype
>         if the scalar type is obviously the same as vectype's.
>         Tweak dump messages.
>
> Index: gcc/tree-vect-stmts.c
> ===================================================================
> --- gcc/tree-vect-stmts.c       2019-10-25 13:27:26.205687511 +0100
> +++ gcc/tree-vect-stmts.c       2019-10-25 13:27:32.877640367 +0100
> @@ -11973,7 +11973,12 @@ vect_get_vector_types_for_stmt (stmt_vec
>    tree vectype;
>    tree scalar_type = NULL_TREE;
>    if (STMT_VINFO_VECTYPE (stmt_info))
> -    *stmt_vectype_out = vectype = STMT_VINFO_VECTYPE (stmt_info);
> +    {
> +      *stmt_vectype_out = vectype = STMT_VINFO_VECTYPE (stmt_info);
> +      if (dump_enabled_p ())
> +       dump_printf_loc (MSG_NOTE, vect_location,
> +                        "precomputed vectype: %T\n", vectype);
> +    }
>    else
>      {
>        gcc_assert (!STMT_VINFO_DATA_REF (stmt_info));
> @@ -12005,7 +12010,7 @@ vect_get_vector_types_for_stmt (stmt_vec
>
>        if (dump_enabled_p ())
>         dump_printf_loc (MSG_NOTE, vect_location,
> -                        "get vectype for scalar type:  %T\n", scalar_type);
> +                        "get vectype for scalar type: %T\n", scalar_type);
>        vectype = get_vectype_for_scalar_type (vinfo, scalar_type);
>        if (!vectype)
>         return opt_result::failure_at (stmt,
> @@ -12022,42 +12027,38 @@ vect_get_vector_types_for_stmt (stmt_vec
>
>    /* Don't try to compute scalar types if the stmt produces a boolean
>       vector; use the existing vector type instead.  */
> -  tree nunits_vectype;
> -  if (VECTOR_BOOLEAN_TYPE_P (vectype))
> -    nunits_vectype = vectype;
> -  else
> +  tree nunits_vectype = vectype;
> +  if (!VECTOR_BOOLEAN_TYPE_P (vectype)
> +      && *stmt_vectype_out != boolean_type_node)
>      {
>        /* The number of units is set according to the smallest scalar
>          type (or the largest vector size, but we only support one
>          vector size per vectorization).  */
> -      if (*stmt_vectype_out != boolean_type_node)
> +      HOST_WIDE_INT dummy;
> +      scalar_type = vect_get_smallest_scalar_type (stmt_info, &dummy, &dummy);
> +      if (scalar_type != TREE_TYPE (vectype))
>         {
> -         HOST_WIDE_INT dummy;
> -         scalar_type = vect_get_smallest_scalar_type (stmt_info,
> -                                                      &dummy, &dummy);
> +         if (dump_enabled_p ())
> +           dump_printf_loc (MSG_NOTE, vect_location,
> +                            "get vectype for smallest scalar type: %T\n",
> +                            scalar_type);
> +         nunits_vectype = get_vectype_for_scalar_type (vinfo, scalar_type);
> +         if (!nunits_vectype)
> +           return opt_result::failure_at
> +             (stmt, "not vectorized: unsupported data-type %T\n",
> +              scalar_type);
> +         if (dump_enabled_p ())
> +           dump_printf_loc (MSG_NOTE, vect_location, "nunits vectype: %T\n",
> +                            nunits_vectype);
>         }
> -      if (dump_enabled_p ())
> -       dump_printf_loc (MSG_NOTE, vect_location,
> -                        "get vectype for scalar type:  %T\n", scalar_type);
> -      nunits_vectype = get_vectype_for_scalar_type (vinfo, scalar_type);
>      }
> -  if (!nunits_vectype)
> -    return opt_result::failure_at (stmt,
> -                                  "not vectorized: unsupported data-type %T\n",
> -                                  scalar_type);
> -
> -  if (maybe_ne (GET_MODE_SIZE (TYPE_MODE (vectype)),
> -               GET_MODE_SIZE (TYPE_MODE (nunits_vectype))))
> -    return opt_result::failure_at (stmt,
> -                                  "not vectorized: different sized vector "
> -                                  "types in statement, %T and %T\n",
> -                                  vectype, nunits_vectype);
> +
> +  gcc_assert (*stmt_vectype_out == boolean_type_node
> +             || multiple_p (TYPE_VECTOR_SUBPARTS (nunits_vectype),
> +                            TYPE_VECTOR_SUBPARTS (*stmt_vectype_out)));
>
>    if (dump_enabled_p ())
>      {
> -      dump_printf_loc (MSG_NOTE, vect_location, "vectype: %T\n",
> -                      nunits_vectype);
> -
>        dump_printf_loc (MSG_NOTE, vect_location, "nunits = ");
>        dump_dec (MSG_NOTE, TYPE_VECTOR_SUBPARTS (nunits_vectype));
>        dump_printf (MSG_NOTE, "\n");

  reply	other threads:[~2019-11-05 12:58 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25 12:32 [0/n] Support multiple vector sizes for vectorisation Richard Sandiford
2019-10-25 12:34 ` [7/n] Use consistent compatibility checks in vectorizable_shift Richard Sandiford
2019-10-30 14:33   ` Richard Biener
2019-10-25 12:34 ` [6/n] Use build_vector_type_for_mode in get_vectype_for_scalar_type_and_size Richard Sandiford
2019-10-30 14:32   ` Richard Biener
2019-10-25 12:39 ` [8/n] Replace autovectorize_vector_sizes with autovectorize_vector_modes Richard Sandiford
2019-10-30 14:48   ` Richard Biener
2019-10-30 16:33     ` Richard Sandiford
2019-11-11 10:30       ` Richard Sandiford
2019-11-11 14:33       ` Richard Biener
2019-11-12 17:55         ` Richard Sandiford
2019-11-13 14:32           ` Richard Biener
2019-11-13 16:16             ` Richard Sandiford
2019-10-25 12:41 ` [9/n] Replace vec_info::vector_size with vec_info::vector_mode Richard Sandiford
2019-11-05 12:47   ` Richard Biener
2019-10-25 12:43 ` [10/n] Make less use of get_same_sized_vectype Richard Sandiford
2019-11-05 12:50   ` Richard Biener
2019-11-05 15:34     ` Richard Sandiford
2019-11-05 16:09       ` Richard Biener
2019-10-25 12:44 ` [11/n] Support vectorisation with mixed vector sizes Richard Sandiford
2019-11-05 12:57   ` Richard Biener
2019-11-06 12:38     ` Richard Sandiford
2019-11-12  9:22       ` Richard Biener
2019-10-25 12:49 ` [12/n] [AArch64] Support vectorising with multiple " Richard Sandiford
2019-10-25 12:51 ` [13/n] Allow mixed vector sizes within a single vectorised stmt Richard Sandiford
2019-11-05 12:58   ` Richard Biener [this message]
2019-10-25 13:00 ` [14/n] Vectorise conversions between differently-sized integer vectors Richard Sandiford
2019-11-05 13:02   ` Richard Biener
2019-11-06 12:45     ` Richard Sandiford
2019-11-12  9:40       ` Richard Biener
2019-10-29 17:05 ` [15/n] Consider building nodes from scalars in vect_slp_analyze_node_operations Richard Sandiford
2019-11-05 13:07   ` Richard Biener
2019-10-29 17:14 ` [16/n] Apply maximum nunits for BB SLP Richard Sandiford
2019-11-05 13:22   ` Richard Biener
2019-11-05 14:09     ` Richard Sandiford
2019-11-14 12:22       ` Richard Biener
2019-11-05 20:10 ` [10a/n] Require equal type sizes for vectorised calls Richard Sandiford
2019-11-06  9:44   ` Richard Biener
2019-11-05 20:25 ` [11a/n] Avoid retrying with the same vector modes Richard Sandiford
2019-11-06  9:49   ` Richard Biener
2019-11-06 10:21     ` Richard Sandiford
2019-11-06 10:27       ` Richard Biener
2019-11-06 11:02         ` Richard Sandiford
2019-11-06 11:22           ` Richard Biener
2019-11-06 12:47             ` Richard Sandiford
2019-11-12  9:25               ` Richard Biener
2019-11-05 20:45 ` [17/17] Extend can_duplicate_and_interleave_p to mixed-size vectors Richard Sandiford
2019-11-14 12:23   ` 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=CAFiYyc3ptxqKYYQnDhO1J2AOcjKp2bF35nhhKKHAvR2XVqPFBg@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).