aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-01-03 07:15:47 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-01-03 07:15:47 +0000
commite54dd6d3a791536543d4769aa09508b89d882f37 (patch)
treedb4448d26a9b2471ac93890a2efe92185d049fe5 /gcc/tree.c
parent9031b367ac87550552318f6516487c70f3ce9a99 (diff)
downloadgcc-e54dd6d3a791536543d4769aa09508b89d882f37.zip
gcc-e54dd6d3a791536543d4769aa09508b89d882f37.tar.gz
gcc-e54dd6d3a791536543d4769aa09508b89d882f37.tar.bz2
poly_int: vectorizable_reduction
This patch makes vectorizable_reduction cope with variable-length vectors. We can handle the simple case of an inner loop reduction for which the target has native support for the epilogue operation. For now we punt on other cases, but patches after the main SVE submission allow SLP and double reductions too. 2018-01-03 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (build_index_vector): Declare. * tree.c (build_index_vector): New function. * tree-vect-loop.c (get_initial_defs_for_reduction): Treat the number of units as polynomial, forcibly converting it to a constant if vectorizable_reduction has already enforced the condition. (vect_create_epilog_for_reduction): Likewise. Use build_index_vector to create a {1,2,3,...} vector. (vectorizable_reduction): Treat the number of units as polynomial. Choose vectype_in based on the largest scalar element size rather than the smallest number of units. Enforce the restrictions relied on above. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r256133
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index f13e2d8..93c4654 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1930,6 +1930,29 @@ build_vec_series (tree type, tree base, tree step)
return build2 (VEC_SERIES_EXPR, type, base, step);
}
+/* Return a vector with the same number of units and number of bits
+ as VEC_TYPE, but in which the elements are a linear series of unsigned
+ integers { BASE, BASE + STEP, BASE + STEP * 2, ... }. */
+
+tree
+build_index_vector (tree vec_type, poly_uint64 base, poly_uint64 step)
+{
+ tree index_vec_type = vec_type;
+ tree index_elt_type = TREE_TYPE (vec_type);
+ poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vec_type);
+ if (!INTEGRAL_TYPE_P (index_elt_type) || !TYPE_UNSIGNED (index_elt_type))
+ {
+ index_elt_type = build_nonstandard_integer_type
+ (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (index_elt_type)), true);
+ index_vec_type = build_vector_type (index_elt_type, nunits);
+ }
+
+ tree_vector_builder v (index_vec_type, 1, 3);
+ for (unsigned int i = 0; i < 3; ++i)
+ v.quick_push (build_int_cstu (index_elt_type, base + i * step));
+ return v.build ();
+}
+
/* Something has messed with the elements of CONSTRUCTOR C after it was built;
calculate TREE_CONSTANT and TREE_SIDE_EFFECTS. */