aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-05-18 16:05:56 +0200
committerRichard Biener <rguenther@suse.de>2020-05-22 12:26:27 +0200
commit79f0451c67e8ed564b86a38581d5f3d57c5074d8 (patch)
tree6d021593ca3438568971032ee89debbba1a036c2 /gcc/tree-vect-loop.c
parentb6ed2e2bca54d1d290f553549d28b0c60a0f240f (diff)
downloadgcc-79f0451c67e8ed564b86a38581d5f3d57c5074d8.zip
gcc-79f0451c67e8ed564b86a38581d5f3d57c5074d8.tar.gz
gcc-79f0451c67e8ed564b86a38581d5f3d57c5074d8.tar.bz2
enfoce SLP_TREE_VECTYPE for invariants
This tries to enforce a set SLP_TREE_VECTYPE in vect_get_constant_vectors and provides some infrastructure for setting it in the vectorizable_* functions, amending those. 2020-05-22 Richard Biener <rguenther@suse.de> * tree-vectorizer.h (vect_is_simple_use): New overload. (vect_maybe_update_slp_op_vectype): New. * tree-vect-stmts.c (vect_is_simple_use): New overload accessing operands of SLP vs. non-SLP operation transparently. (vect_maybe_update_slp_op_vectype): New function updating the possibly shared SLP operands vector type. (vectorizable_operation): Be a bit more SLP vs non-SLP agnostic using the new vect_is_simple_use overload; update SLP invariant operand nodes vector type. (vectorizable_comparison): Likewise. (vectorizable_call): Likewise. (vectorizable_conversion): Likewise. (vectorizable_shift): Likewise. (vectorizable_store): Likewise. (vectorizable_condition): Likewise. (vectorizable_assignment): Likewise. * tree-vect-loop.c (vectorizable_reduction): Likewise. * tree-vect-slp.c (vect_get_constant_vectors): Enforce present SLP_TREE_VECTYPE and check it matches previous behavior.
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index ecce348..4f94b4b 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -6185,17 +6185,29 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
The last use is the reduction variable. In case of nested cycle this
assumption is not true: we use reduc_index to record the index of the
reduction variable. */
- reduc_def = PHI_RESULT (reduc_def_phi);
+ /* ??? To get at invariant/constant uses on the SLP node we have to
+ get to it here, slp_node is still the reduction PHI. */
+ slp_tree slp_for_stmt_info = NULL;
+ if (slp_node)
+ {
+ slp_for_stmt_info = slp_node_instance->root;
+ /* And then there's reduction chain with a conversion ... */
+ if (SLP_TREE_SCALAR_STMTS (slp_for_stmt_info)[0] != stmt_info)
+ slp_for_stmt_info = SLP_TREE_CHILDREN (slp_for_stmt_info)[0];
+ gcc_assert (SLP_TREE_SCALAR_STMTS (slp_for_stmt_info)[0] == stmt_info);
+ }
+ slp_tree *slp_op = XALLOCAVEC (slp_tree, op_type);
for (i = 0; i < op_type; i++)
{
- tree op = gimple_op (stmt, i + 1);
/* The condition of COND_EXPR is checked in vectorizable_condition(). */
if (i == 0 && code == COND_EXPR)
continue;
stmt_vec_info def_stmt_info;
enum vect_def_type dt;
- if (!vect_is_simple_use (op, loop_vinfo, &dt, &tem,
+ tree op;
+ if (!vect_is_simple_use (loop_vinfo, stmt_info, slp_for_stmt_info,
+ i, &op, &slp_op[i], &dt, &tem,
&def_stmt_info))
{
if (dump_enabled_p ())
@@ -6729,6 +6741,21 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
return false;
}
+ if (slp_node
+ && !(!single_defuse_cycle
+ && code != DOT_PROD_EXPR
+ && code != WIDEN_SUM_EXPR
+ && code != SAD_EXPR
+ && reduction_type != FOLD_LEFT_REDUCTION))
+ for (i = 0; i < op_type; i++)
+ if (!vect_maybe_update_slp_op_vectype (slp_op[i], vectype_in))
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "incompatible vector types for invariants\n");
+ return false;
+ }
+
if (slp_node)
vec_num = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node);
else