diff options
author | Richard Biener <rguenther@suse.de> | 2024-06-10 10:12:52 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2024-06-10 11:38:41 +0200 |
commit | 4ed9c5df7efeb98e190573cca42a4fd40666c45f (patch) | |
tree | 9ac7e9d9cb353f3fef53aefe38828c68c249adb4 /gcc/tree-vect-loop.cc | |
parent | 627244477949da068456dc195a88be5437e11d02 (diff) | |
download | gcc-4ed9c5df7efeb98e190573cca42a4fd40666c45f.zip gcc-4ed9c5df7efeb98e190573cca42a4fd40666c45f.tar.gz gcc-4ed9c5df7efeb98e190573cca42a4fd40666c45f.tar.bz2 |
tree-optimization/115395 - wrong-code with SLP reduction in epilog
When we continue a non-SLP reduction from the main loop in the
epilog with a SLP reduction we currently fail to handle an
adjustment by the initial value because that's not a thing with SLP.
As long as we have the possibility to mix SLP and non-SLP we have
to handle it though.
PR tree-optimization/115395
* tree-vect-loop.cc (vect_create_epilog_for_reduction):
Handle STMT_VINFO_REDUC_EPILOGUE_ADJUSTMENT also for SLP
reductions of group_size one.
* gcc.dg/vect/pr115395.c: New testcase.
Diffstat (limited to 'gcc/tree-vect-loop.cc')
-rw-r--r-- | gcc/tree-vect-loop.cc | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 0286926..c471f15 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -6030,25 +6030,14 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, tree induc_val = NULL_TREE; tree adjustment_def = NULL; - if (slp_node) - { - /* Optimize: for induction condition reduction, if we can't use zero - for induc_val, use initial_def. */ - if (STMT_VINFO_REDUC_TYPE (reduc_info) == INTEGER_INDUC_COND_REDUCTION) - induc_val = STMT_VINFO_VEC_INDUC_COND_INITIAL_VAL (reduc_info); - /* ??? Coverage for 'else' isn't clear. */ - } + /* Optimize: for induction condition reduction, if we can't use zero + for induc_val, use initial_def. */ + if (STMT_VINFO_REDUC_TYPE (reduc_info) == INTEGER_INDUC_COND_REDUCTION) + induc_val = STMT_VINFO_VEC_INDUC_COND_INITIAL_VAL (reduc_info); + else if (double_reduc) + ; else - { - /* Optimize: for induction condition reduction, if we can't use zero - for induc_val, use initial_def. */ - if (STMT_VINFO_REDUC_TYPE (reduc_info) == INTEGER_INDUC_COND_REDUCTION) - induc_val = STMT_VINFO_VEC_INDUC_COND_INITIAL_VAL (reduc_info); - else if (double_reduc) - ; - else - adjustment_def = STMT_VINFO_REDUC_EPILOGUE_ADJUSTMENT (reduc_info); - } + adjustment_def = STMT_VINFO_REDUC_EPILOGUE_ADJUSTMENT (reduc_info); stmt_vec_info single_live_out_stmt[] = { stmt_info }; array_slice<const stmt_vec_info> live_out_stmts = single_live_out_stmt; @@ -6873,7 +6862,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, if (adjustment_def) { - gcc_assert (!slp_reduc); + gcc_assert (!slp_reduc || group_size == 1); gimple_seq stmts = NULL; if (double_reduc) { |