Commit fa780794 by Richard Sandiford Committed by Richard Sandiford

poly_int: vectorizable_live_operation

This patch makes vectorizable_live_operation cope with variable-length
vectors.  For now we just handle cases in which we can tell at compile
time which vector contains the final result.

2018-01-03  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* tree-vect-loop.c (vectorizable_live_operation): Treat the number
	of units as polynomial.  Punt if we can't tell at compile time
	which vector contains the final result.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r256135
parent 9fb9293a
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* tree-vect-loop.c (vectorizable_live_operation): Treat the number
of units as polynomial. Punt if we can't tell at compile time
which vector contains the final result.
2018-01-03 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* tree-vect-loop.c (vectorizable_induction): Treat the number * tree-vect-loop.c (vectorizable_induction): Treat the number
of units as polynomial. Punt on SLP inductions. Use an integer of units as polynomial. Punt on SLP inductions. Use an integer
VEC_SERIES_EXPR for variable-length integer reductions. Use a VEC_SERIES_EXPR for variable-length integer reductions. Use a
...@@ -7201,10 +7201,12 @@ vectorizable_live_operation (gimple *stmt, ...@@ -7201,10 +7201,12 @@ vectorizable_live_operation (gimple *stmt,
imm_use_iterator imm_iter; imm_use_iterator imm_iter;
tree lhs, lhs_type, bitsize, vec_bitsize; tree lhs, lhs_type, bitsize, vec_bitsize;
tree vectype = STMT_VINFO_VECTYPE (stmt_info); tree vectype = STMT_VINFO_VECTYPE (stmt_info);
int nunits = TYPE_VECTOR_SUBPARTS (vectype); poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype);
int ncopies; int ncopies;
gimple *use_stmt; gimple *use_stmt;
auto_vec<tree> vec_oprnds; auto_vec<tree> vec_oprnds;
int vec_entry = 0;
poly_uint64 vec_index = 0;
gcc_assert (STMT_VINFO_LIVE_P (stmt_info)); gcc_assert (STMT_VINFO_LIVE_P (stmt_info));
...@@ -7233,6 +7235,30 @@ vectorizable_live_operation (gimple *stmt, ...@@ -7233,6 +7235,30 @@ vectorizable_live_operation (gimple *stmt,
else else
ncopies = vect_get_num_copies (loop_vinfo, vectype); ncopies = vect_get_num_copies (loop_vinfo, vectype);
if (slp_node)
{
gcc_assert (slp_index >= 0);
int num_scalar = SLP_TREE_SCALAR_STMTS (slp_node).length ();
int num_vec = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node);
/* Get the last occurrence of the scalar index from the concatenation of
all the slp vectors. Calculate which slp vector it is and the index
within. */
poly_uint64 pos = (num_vec * nunits) - num_scalar + slp_index;
/* Calculate which vector contains the result, and which lane of
that vector we need. */
if (!can_div_trunc_p (pos, nunits, &vec_entry, &vec_index))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
"Cannot determine which vector holds the"
" final result.\n");
return false;
}
}
if (!vec_stmt) if (!vec_stmt)
/* No transformation required. */ /* No transformation required. */
return true; return true;
...@@ -7254,18 +7280,6 @@ vectorizable_live_operation (gimple *stmt, ...@@ -7254,18 +7280,6 @@ vectorizable_live_operation (gimple *stmt,
tree vec_lhs, bitstart; tree vec_lhs, bitstart;
if (slp_node) if (slp_node)
{ {
gcc_assert (slp_index >= 0);
int num_scalar = SLP_TREE_SCALAR_STMTS (slp_node).length ();
int num_vec = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node);
/* Get the last occurrence of the scalar index from the concatenation of
all the slp vectors. Calculate which slp vector it is and the index
within. */
int pos = (num_vec * nunits) - num_scalar + slp_index;
int vec_entry = pos / nunits;
int vec_index = pos % nunits;
/* Get the correct slp vectorized stmt. */ /* Get the correct slp vectorized stmt. */
vec_lhs = gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[vec_entry]); vec_lhs = gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[vec_entry]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment