diff options
author | Richard Biener <rguenther@suse.de> | 2020-08-26 15:12:17 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-08-26 16:02:32 +0200 |
commit | 2130efe6ac7beba72d289e3dd145daa10aeaed54 (patch) | |
tree | 9f9f63553ccafec89b413aea2df46de595dbf809 /gcc/tree-vect-stmts.c | |
parent | 3eefb302d2bd8502cb3d8fe44e672b11092ccaf6 (diff) | |
download | gcc-2130efe6ac7beba72d289e3dd145daa10aeaed54.zip gcc-2130efe6ac7beba72d289e3dd145daa10aeaed54.tar.gz gcc-2130efe6ac7beba72d289e3dd145daa10aeaed54.tar.bz2 |
tree-optimization/96698 - fix ICE when vectorizing nested cycles
This fixes vectorized PHI latch edge updating and delay it until
all of the loop is code generated to deal with the case that the
latch def is a PHI in the same block.
2020-08-26 Richard Biener <rguenther@suse.de>
PR tree-optimization/96698
* tree-vectorizer.h (loop_vec_info::reduc_latch_defs): New.
(loop_vec_info::reduc_latch_slp_defs): Likewise.
* tree-vect-stmts.c (vect_transform_stmt): Only record
stmts to update PHI latches from, perform the update ...
* tree-vect-loop.c (vect_transform_loop): ... here after
vectorizing those PHIs.
(info_for_reduction): Properly handle non-reduction PHIs.
* gcc.dg/vect/pr96698.c: New testcase.
Diffstat (limited to 'gcc/tree-vect-stmts.c')
-rw-r--r-- | gcc/tree-vect-stmts.c | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 224be01..04d202e 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -10920,8 +10920,8 @@ vect_transform_stmt (vec_info *vinfo, if (STMT_VINFO_TYPE (stmt_info) == store_vec_info_type) return is_store; - /* If this stmt defines a value used on a backedge, update the - vectorized PHIs. */ + /* If this stmt defines a value used on a backedge, record it so + we can update the vectorized PHIs later. */ stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info); stmt_vec_info reduc_info; if (STMT_VINFO_REDUC_DEF (orig_stmt_info) @@ -10940,30 +10940,11 @@ vect_transform_stmt (vec_info *vinfo, && (e = loop_latch_edge (gimple_bb (phi)->loop_father)) && (PHI_ARG_DEF_FROM_EDGE (phi, e) == gimple_get_lhs (orig_stmt_info->stmt))) - { - vec<gimple *> &phi_info - = STMT_VINFO_VEC_STMTS (STMT_VINFO_REDUC_DEF (orig_stmt_info)); - vec<gimple *> &vec_stmt - = STMT_VINFO_VEC_STMTS (stmt_info); - gcc_assert (phi_info.length () == vec_stmt.length ()); - for (unsigned i = 0; i < phi_info.length (); ++i) - add_phi_arg (as_a <gphi *> (phi_info[i]), - gimple_get_lhs (vec_stmt[i]), e, - gimple_phi_arg_location (phi, e->dest_idx)); - } + as_a <loop_vec_info> (vinfo)->reduc_latch_defs.safe_push (stmt_info); else if (slp_node && slp_node != slp_node_instance->reduc_phis) - { - slp_tree phi_node = slp_node_instance->reduc_phis; - gphi *phi = as_a <gphi *> (SLP_TREE_SCALAR_STMTS (phi_node)[0]->stmt); - e = loop_latch_edge (gimple_bb (phi)->loop_father); - gcc_assert (SLP_TREE_VEC_STMTS (phi_node).length () - == SLP_TREE_VEC_STMTS (slp_node).length ()); - for (unsigned i = 0; i < SLP_TREE_VEC_STMTS (phi_node).length (); ++i) - add_phi_arg (as_a <gphi *> (SLP_TREE_VEC_STMTS (phi_node)[i]), - vect_get_slp_vect_def (slp_node, i), - e, gimple_phi_arg_location (phi, e->dest_idx)); - } + as_a <loop_vec_info> (vinfo)->reduc_latch_slp_defs.safe_push + (std::make_pair (slp_node, slp_node_instance->reduc_phis)); } /* Handle stmts whose DEF is used outside the loop-nest that is |