https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115841
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:59ed01d5e3d2b0e59163d3248bdba9f1e35de599 commit r14-10440-g59ed01d5e3d2b0e59163d3248bdba9f1e35de599 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)