https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113178
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tamar Christina <tnfch...@gcc.gnu.org>: https://gcc.gnu.org/g:e79c5855ab39d96baa7c6bec63eb97715abcf68d commit r14-7197-ge79c5855ab39d96baa7c6bec63eb97715abcf68d Author: Tamar Christina <tamar.christ...@arm.com> Date: Fri Jan 12 15:26:29 2024 +0000 middle-end: fill in reduction PHI for all alt exits [PR113178] When we have a loop with more than 2 exits and a reduction I forgot to fill in the PHI value for all alternate exits. All alternate exits use the same PHI value so we should loop over the new PHI elements and copy the value across since we call the reduction calculation code only once for all exits. This was normally covered up by earlier parts of the compiler rejecting loops incorrectly (which has been fixed now). Note that while I can use the loop in all cases, the reason I separated out the main and alt exit is so that if you pass the wrong edge the macro will assert. gcc/ChangeLog: PR tree-optimization/113178 * tree-vect-loop.cc (vect_create_epilog_for_reduction): Fill in all alternate exits. gcc/testsuite/ChangeLog: PR tree-optimization/113178 * gcc.dg/vect/vect-early-break_101-pr113178.c: New test. * gcc.dg/vect/vect-early-break_102-pr113178.c: New test.