https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120352
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tamar Christina <[email protected]>: https://gcc.gnu.org/g:991c35ee974548156c01cb69f093694973468f51 commit r17-836-g991c35ee974548156c01cb69f093694973468f51 Author: Tamar Christina <[email protected]> Date: Wed May 27 10:52:27 2026 +0100 vect: refactor loop peeling to support explicit flag to redirect early exits [PR120352] This patch series is the first in a few to optimize early break vectorization. The first one addresses that certain loops don't require an epilog at all. An example is int a[N] = {0,0,0,1}; int b[N] = {0,0,0,1}; __attribute__((noipa, noinline)) int foo () { for (int i = 0; i < N; i++) { if (a[i] > b[i]) return 1; } return 0; } where we have no value or side-effect to compute. Naturally there's no need to redo any work to just return 1 or 0. Teaching the vectorizer this however re-enabled epilogue nomask for early break and so we still need to be able to peel for the epilogues. This peeling however should not redirect all the alternative exits to the epilog. To understand when this has to happen peeling now gets an extra parameter to indicate how to handle the multiple exits. This had an unfortunate interaction with uncounted loops, because uncounted loops re-used the layout (with the intermediate merge block) but just being a fall through block. When it did this it didn't put all PHI nodes in the final merge block and as such relied on fixups later. This made the actual changed needed for not needing epilogs more fragile than needed so I first refactored peeling to be more consistent between early break and uncounted loops and insure that all BB now explicitly mention and use all PHI nodes from the exits. The code should hopefully be a bit more robust now wrt to needed optimizations. gcc/ChangeLog: PR tree-optimization/120352 * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg): Add redirect_exits. (vect_do_peeling): Use it. * tree-vectorizer.h (slpeel_tree_duplicate_loop_to_edge_cfg): Update prototype.
