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: [6/n] Use build_vector_type_for_mode in get_vectype_for_scalar_type_and_size
Date: Wed, 30 Oct 2019 14:32:00 -0000	[thread overview]
Message-ID: <CAFiYyc34qoLbaTYiqCr+o17fZ32DGGWn8EVhxCgDKTnXFOYHmQ@mail.gmail.com> (raw)
In-Reply-To: <mptk18t9fac.fsf@arm.com>

On Fri, Oct 25, 2019 at 2:32 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> Except for one case, get_vectype_for_scalar_type_and_size calculates
> what the vector mode should be and then calls build_vector_type,
> which recomputes the mode from scratch.  This patch makes it use
> build_vector_type_for_mode instead.
>
> The exception mentioned above is when preferred_simd_mode returns
> an integer mode, which it does if no appropriate vector mode exists.
> The integer mode in question is usually word_mode, although epiphany
> can return a doubleword mode in some cases.
>
> There's no guarantee that this integer mode is appropriate, since for
> example the scalar type could be a float.  The traditional behaviour is
> therefore to use the integer mode to determine a size only, and leave
> mode_for_vector to pick the TYPE_MODE.  (Note that it can actually end
> up picking a vector mode if the target defines a disabled vector mode.
> We therefore still need to check TYPE_MODE after building the type.)

OK.

Thanks,
Richard.

>
> 2019-10-24  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * tree-vect-stmts.c (get_vectype_for_scalar_type_and_size): If
>         targetm.vectorize.preferred_simd_mode returns an integer mode,
>         use mode_for_vector to decide what the vector type's mode
>         should actually be.  Use build_vector_type_for_mode instead
>         of build_vector_type.
>
> Index: gcc/tree-vect-stmts.c
> ===================================================================
> --- gcc/tree-vect-stmts.c       2019-10-25 13:26:59.309877555 +0100
> +++ gcc/tree-vect-stmts.c       2019-10-25 13:27:08.653811531 +0100
> @@ -11162,16 +11162,31 @@ get_vectype_for_scalar_type_and_size (tr
>    /* If no size was supplied use the mode the target prefers.   Otherwise
>       lookup a vector mode of the specified size.  */
>    if (known_eq (size, 0U))
> -    simd_mode = targetm.vectorize.preferred_simd_mode (inner_mode);
> +    {
> +      simd_mode = targetm.vectorize.preferred_simd_mode (inner_mode);
> +      if (SCALAR_INT_MODE_P (simd_mode))
> +       {
> +         /* Traditional behavior is not to take the integer mode
> +            literally, but simply to use it as a way of determining
> +            the vector size.  It is up to mode_for_vector to decide
> +            what the TYPE_MODE should be.
> +
> +            Note that nunits == 1 is allowed in order to support single
> +            element vector types.  */
> +         if (!multiple_p (GET_MODE_SIZE (simd_mode), nbytes, &nunits)
> +             || !mode_for_vector (inner_mode, nunits).exists (&simd_mode))
> +           return NULL_TREE;
> +       }
> +    }
>    else if (!multiple_p (size, nbytes, &nunits)
>            || !mode_for_vector (inner_mode, nunits).exists (&simd_mode))
>      return NULL_TREE;
> -  /* NOTE: nunits == 1 is allowed to support single element vector types.  */
> -  if (!multiple_p (GET_MODE_SIZE (simd_mode), nbytes, &nunits))
> -    return NULL_TREE;
>
> -  vectype = build_vector_type (scalar_type, nunits);
> +  vectype = build_vector_type_for_mode (scalar_type, simd_mode);
>
> +  /* In cases where the mode was chosen by mode_for_vector, check that
> +     the target actually supports the chosen mode, or that it at least
> +     allows the vector mode to be replaced by a like-sized integer.  */
>    if (!VECTOR_MODE_P (TYPE_MODE (vectype))
>        && !INTEGRAL_MODE_P (TYPE_MODE (vectype)))
>      return NULL_TREE;

  reply	other threads:[~2019-10-30 14:29 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 [this message]
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
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=CAFiYyc34qoLbaTYiqCr+o17fZ32DGGWn8EVhxCgDKTnXFOYHmQ@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).