Handle poly_int vector sizes in get_vec_alignment_for_array_type
authorRichard Sandiford <richard.sandiford@linaro.org>
Fri, 12 Jan 2018 14:48:35 +0000 (14:48 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Fri, 12 Jan 2018 14:48:35 +0000 (14:48 +0000)
get_vectype_for_scalar_type returns a variable-length vector type
for SVE, whereas get_vec_alignment_for_array_type assumed it would
always be an INTEGER_CST.

This is needed to build libstdc++-v3/src/closures.cc for SVE
(and probably many other places besides -- this was just the
first hit).

2018-01-12  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
* tree-vectorizer.c (get_vec_alignment_for_array_type): Handle
polynomial type sizes.

From-SVN: r256586

gcc/ChangeLog
gcc/tree-vectorizer.c

index 823f39d1d877b5c0422b8244bb362309fbbd6a98..7195a2a729f0b4720eb6f7b59077c9f374579eec 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-12  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       * tree-vectorizer.c (get_vec_alignment_for_array_type): Handle
+       polynomial type sizes.
+
 2018-01-12  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * gimplify.c (gimple_add_tmp_var_fn): Allow variables to have a
index b5bdf676881a13cbddf341c34f24a835ca7356ed..a0cc2d6bddb5a906d13f02300c90d5be1f687158 100644 (file)
@@ -1015,12 +1015,13 @@ static unsigned
 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));
   if (!vectype
-      || !TYPE_SIZE (type)
-      || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
-      || tree_int_cst_lt (TYPE_SIZE (type), TYPE_SIZE (vectype)))
+      || !poly_int_tree_p (TYPE_SIZE (type), &array_size)
+      || !poly_int_tree_p (TYPE_SIZE (vectype), &vector_size)
+      || maybe_lt (array_size, vector_size))
     return 0;
 
   return TYPE_ALIGN (vectype);