https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115841
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:e87c0c7f7ab1e7acd0ffbac0b15e020275f97ca8 commit r13-9041-ge87c0c7f7ab1e7acd0ffbac0b15e020275f97ca8 Author: Richard Biener <rguent...@suse.de> Date: Tue Jul 16 11:53:17 2024 +0200 tree-optimization/115841 - reduction epilogue placement issue When emitting the compensation to the vectorized main loop for a vector reduction value to be re-used in the vectorized epilogue we fail to place it in the correct block when the main loop is known to be entered (no loop_vinfo->main_loop_edge) but the epilogue is not (a loop_vinfo->skip_this_loop_edge). The code currently disregards this situation. With the recent znver4 cost fix I couldn't trigger this situation with the testcase but I adjusted it so it could eventually trigger on other targets. PR tree-optimization/115841 * tree-vect-loop.cc (vect_transform_cycle_phi): Correctly place the partial vector reduction for the accumulator re-use when the main loop cannot be skipped but the epilogue can. * gcc.dg/vect/pr115841.c: New testcase. (cherry picked from commit 016c947b02e79a5c0c0c2d4ad5cb71aa04db3efd)