Message ID | 87h8rr19rb.fsf_-_@linaro.org |
---|---|
State | Accepted |
Commit | cf736b092afeabe90680443794eb384a9f930cd5 |
Headers | show |
Series | Handle poly_int vector sizes in get_vec_alignment_for_array_type | expand |
On Fri, Jan 12, 2018 at 2:34 PM, Richard Sandiford <richard.sandiford@linaro.org> wrote: > 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). > > Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. > Also tested by comparing the before-and-after assembly output for at > least one target per CPU directory. OK to install? Ok. Richard. > Thanks, > Richard > > > 2018-01-12 Richard Sandiford <richard.sandiford@linaro.org> > > gcc/ > * tree-vectorizer.c (get_vec_alignment_for_array_type): Handle > polynomial type sizes. > > Index: gcc/tree-vectorizer.c > =================================================================== > --- gcc/tree-vectorizer.c 2018-01-10 08:43:40.053367209 +0000 > +++ gcc/tree-vectorizer.c 2018-01-12 12:56:30.428743723 +0000 > @@ -1015,12 +1015,13 @@ static unsigned get_vec_alignment_for_ty > 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);
Index: gcc/tree-vectorizer.c =================================================================== --- gcc/tree-vectorizer.c 2018-01-10 08:43:40.053367209 +0000 +++ gcc/tree-vectorizer.c 2018-01-12 12:56:30.428743723 +0000 @@ -1015,12 +1015,13 @@ static unsigned get_vec_alignment_for_ty 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);