Avoid setting current_vector_size in get_vec_alignment_for_array_type
authorRichard Sandiford <richard.sandiford@arm.com>
Mon, 21 Oct 2019 06:40:36 +0000 (06:40 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Mon, 21 Oct 2019 06:40:36 +0000 (06:40 +0000)
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-21  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.

From-SVN: r277223

gcc/ChangeLog
gcc/tree-vectorizer.c

index a68d0fc6f00e6bcc0b503e8199816db39cbc8284..4460d1e9e9da909e304986e66ffde0b25e84eacf 100644 (file)
@@ -1,3 +1,9 @@
+2019-10-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * tree-vectorizer.c (get_vec_alignment_for_array_type): Use
+       get_vectype_for_scalar_type_and_size instead of
+       get_vectype_for_scalar_type.
+
 2019-10-20  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * common.opt (-fcommon): Fix description.
index 1a0cc93582b3fbb01d7797b15728f2abc70182f8..0c0c018fd8eda28fd0589be76b72d0f675666709 100644 (file)
@@ -1347,7 +1347,8 @@ get_vec_alignment_for_array_type (tree type)
   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)