diff options
author | Richard Biener <rguenther@suse.de> | 2024-08-06 09:50:00 +0200 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2024-08-06 12:49:15 +0200 |
commit | 31efd46ad8a16aa671f4502816b6b1f9946027ae (patch) | |
tree | 980e7e6c017d2ff6dedac588a874c8fcce1855ca /gcc/tree-vect-loop.cc | |
parent | df4062c54b0b3c5f5c6a1f1a2454abf965100e3a (diff) | |
download | gcc-31efd46ad8a16aa671f4502816b6b1f9946027ae.zip gcc-31efd46ad8a16aa671f4502816b6b1f9946027ae.tar.gz gcc-31efd46ad8a16aa671f4502816b6b1f9946027ae.tar.bz2 |
tree-optimization/116241 - ICE with SLP condition reduction
When there's a conversion in front of a SLP condition reduction the
code following the reduc-idx SLP chain fails because it assumes
there's only COND_EXPRs.
PR tree-optimization/116241
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Handle
non-COND_EXPR nodes in SLP reduction chain following.
* g++.dg/vect/pr116241.cc: New testcase.
Diffstat (limited to 'gcc/tree-vect-loop.cc')
-rw-r--r-- | gcc/tree-vect-loop.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 856ce49..6456220 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -6075,6 +6075,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, while (cond_node != slp_node_instance->reduc_phis) { stmt_vec_info cond_info = SLP_TREE_REPRESENTATIVE (cond_node); + int slp_reduc_idx; if (gimple_assign_rhs_code (cond_info->stmt) == COND_EXPR) { gimple *vec_stmt @@ -6083,13 +6084,15 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, ccompares.safe_push (std::make_pair (gimple_assign_rhs1 (vec_stmt), STMT_VINFO_REDUC_IDX (cond_info) == 2)); - } - /* ??? We probably want to have REDUC_IDX on the SLP node? - We have both three and four children COND_EXPR nodes - dependent on whether the comparison is still embedded - as GENERIC. So work backwards. */ - int slp_reduc_idx = (SLP_TREE_CHILDREN (cond_node).length () - 3 + /* ??? We probably want to have REDUC_IDX on the SLP node? + We have both three and four children COND_EXPR nodes + dependent on whether the comparison is still embedded + as GENERIC. So work backwards. */ + slp_reduc_idx = (SLP_TREE_CHILDREN (cond_node).length () - 3 + STMT_VINFO_REDUC_IDX (cond_info)); + } + else + slp_reduc_idx = STMT_VINFO_REDUC_IDX (cond_info); cond_node = SLP_TREE_CHILDREN (cond_node)[slp_reduc_idx]; } } |