diff mbox series

[1/3] Avoid setting current_vector_size in get_vec_alignment_for_array_type

Message ID mptk18zlff7.fsf@arm.com
State New
Headers show
Series Turn current_vector_size into a vec_info field | expand

Commit Message

Richard Sandiford Oct. 20, 2019, 1:22 p.m. UTC
The increase_alignment pass was using get_vectype_for_scalar_type
to get the preferred vector type for each array element type.
This has the effect of carrying over the vector size chosen by
the first successful call to all subsequent calls, whereas it seems
more natural to treat each array type independently and pick the
"best" vector type for each element type.


2019-10-20  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vectorizer.c (get_vec_alignment_for_array_type): Use
	get_vectype_for_scalar_type_and_size instead of
	get_vectype_for_scalar_type.

Comments

Richard Biener Oct. 30, 2019, 2:21 p.m. UTC | #1
On Sun, Oct 20, 2019 at 3:23 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> The increase_alignment pass was using get_vectype_for_scalar_type
> to get the preferred vector type for each array element type.
> This has the effect of carrying over the vector size chosen by
> the first successful call to all subsequent calls, whereas it seems
> more natural to treat each array type independently and pick the
> "best" vector type for each element type.

OK.

>
> 2019-10-20  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * tree-vectorizer.c (get_vec_alignment_for_array_type): Use
>         get_vectype_for_scalar_type_and_size instead of
>         get_vectype_for_scalar_type.
>
> Index: gcc/tree-vectorizer.c
> ===================================================================
> --- gcc/tree-vectorizer.c       2019-10-20 13:58:02.091634417 +0100
> +++ gcc/tree-vectorizer.c       2019-10-20 14:13:50.784857051 +0100
> @@ -1347,7 +1347,8 @@ get_vec_alignment_for_array_type (tree t
>    gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
>    poly_uint64 array_size, vector_size;
>
> -  tree vectype = get_vectype_for_scalar_type (strip_array_types (type));
> +  tree scalar_type = strip_array_types (type);
> +  tree vectype = get_vectype_for_scalar_type_and_size (scalar_type, 0);
>    if (!vectype
>        || !poly_int_tree_p (TYPE_SIZE (type), &array_size)
>        || !poly_int_tree_p (TYPE_SIZE (vectype), &vector_size)
diff mbox series

Patch

Index: gcc/tree-vectorizer.c
===================================================================
--- gcc/tree-vectorizer.c	2019-10-20 13:58:02.091634417 +0100
+++ gcc/tree-vectorizer.c	2019-10-20 14:13:50.784857051 +0100
@@ -1347,7 +1347,8 @@  get_vec_alignment_for_array_type (tree t
   gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
   poly_uint64 array_size, vector_size;
 
-  tree vectype = get_vectype_for_scalar_type (strip_array_types (type));
+  tree scalar_type = strip_array_types (type);
+  tree vectype = get_vectype_for_scalar_type_and_size (scalar_type, 0);
   if (!vectype
       || !poly_int_tree_p (TYPE_SIZE (type), &array_size)
       || !poly_int_tree_p (TYPE_SIZE (vectype), &vector_size)