aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-11-08 16:08:03 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-11-08 16:08:03 +0000
commitd308ca27c71e43625b378dc6c2774105867d4fa7 (patch)
treef10d05368dc74046b05aa79baa3a0ae7fda28b41 /gcc/tree-vect-loop.c
parentfd14d6cbc4c82fd22a77d7c38ec37b5c8a97f23c (diff)
downloadgcc-d308ca27c71e43625b378dc6c2774105867d4fa7.zip
gcc-d308ca27c71e43625b378dc6c2774105867d4fa7.tar.gz
gcc-d308ca27c71e43625b378dc6c2774105867d4fa7.tar.bz2
Use correct vector type in neutral_op_for_slp_reduction
With the new reduction vectype handling, neutral_op_for_slp_reduction needs to know whether the caller is using STMT_VINFO_REDUC_VECTYPE (for an epilogue value) or STMT_VINFO_VECTYPE (for a PHI argument). This fixes various gcc.target/aarch64/sve/slp_* tests. 2019-11-08 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-loop.c (neutral_op_for_slp_reduction): Take the vector type as an argument rather than reading it from the stmt_vec_info. (vect_create_epilog_for_reduction): Update accordingly. (vectorizable_reduction): Likewise. (vect_transform_cycle_phi): Likewise. From-SVN: r277977
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index f25260c..78fe629 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2590,17 +2590,17 @@ reduction_fn_for_scalar_code (enum tree_code code, internal_fn *reduc_fn)
/* If there is a neutral value X such that SLP reduction NODE would not
be affected by the introduction of additional X elements, return that X,
- otherwise return null. CODE is the code of the reduction. REDUC_CHAIN
- is true if the SLP statements perform a single reduction, false if each
- statement performs an independent reduction. */
+ otherwise return null. CODE is the code of the reduction and VECTOR_TYPE
+ is the vector type that would hold element X. REDUC_CHAIN is true if
+ the SLP statements perform a single reduction, false if each statement
+ performs an independent reduction. */
static tree
-neutral_op_for_slp_reduction (slp_tree slp_node, tree_code code,
- bool reduc_chain)
+neutral_op_for_slp_reduction (slp_tree slp_node, tree vector_type,
+ tree_code code, bool reduc_chain)
{
vec<stmt_vec_info> stmts = SLP_TREE_SCALAR_STMTS (slp_node);
stmt_vec_info stmt_vinfo = stmts[0];
- tree vector_type = STMT_VINFO_VECTYPE (stmt_vinfo);
tree scalar_type = TREE_TYPE (vector_type);
class loop *loop = gimple_bb (stmt_vinfo->stmt)->loop_father;
gcc_assert (loop);
@@ -4220,11 +4220,6 @@ vect_create_epilog_for_reduction (stmt_vec_info stmt_info,
= as_a <gphi *> (STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info))->stmt);
enum tree_code code = STMT_VINFO_REDUC_CODE (reduc_info);
internal_fn reduc_fn = STMT_VINFO_REDUC_FN (reduc_info);
- tree neutral_op = NULL_TREE;
- if (slp_node)
- neutral_op
- = neutral_op_for_slp_reduction (slp_node_instance->reduc_phis, code,
- REDUC_GROUP_FIRST_ELEMENT (stmt_info));
stmt_vec_info prev_phi_info;
tree vectype;
machine_mode mode;
@@ -4822,6 +4817,14 @@ vect_create_epilog_for_reduction (stmt_vec_info stmt_info,
scalar value if we have one, otherwise the initial scalar value
is itself a neutral value. */
tree vector_identity = NULL_TREE;
+ tree neutral_op = NULL_TREE;
+ if (slp_node)
+ {
+ stmt_vec_info first = REDUC_GROUP_FIRST_ELEMENT (stmt_info);
+ neutral_op
+ = neutral_op_for_slp_reduction (slp_node_instance->reduc_phis,
+ vectype, code, first != NULL);
+ }
if (neutral_op)
vector_identity = gimple_build_vector_from_val (&seq, vectype,
neutral_op);
@@ -6214,7 +6217,7 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node,
tree neutral_op = NULL_TREE;
if (slp_node)
neutral_op = neutral_op_for_slp_reduction
- (slp_node_instance->reduc_phis, orig_code,
+ (slp_node_instance->reduc_phis, vectype_out, orig_code,
REDUC_GROUP_FIRST_ELEMENT (stmt_info) != NULL);
if (double_reduc && reduction_type == FOLD_LEFT_REDUCTION)
@@ -6797,7 +6800,7 @@ vect_transform_cycle_phi (stmt_vec_info stmt_info, stmt_vec_info *vec_stmt,
gcc_assert (slp_node == slp_node_instance->reduc_phis);
stmt_vec_info first = REDUC_GROUP_FIRST_ELEMENT (reduc_stmt_info);
tree neutral_op
- = neutral_op_for_slp_reduction (slp_node,
+ = neutral_op_for_slp_reduction (slp_node, vectype_out,
STMT_VINFO_REDUC_CODE (reduc_info),
first != NULL);
get_initial_defs_for_reduction (slp_node_instance->reduc_phis,