https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111387
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:04238615bba435f0b0ca7b263ad2c6bdb596e865 commit r14-3920-g04238615bba435f0b0ca7b263ad2c6bdb596e865 Author: Richard Biener <rguent...@suse.de> Date: Wed Sep 13 11:04:31 2023 +0200 tree-optimization/111387 - BB SLP and irreducible regions When we split an irreducible region for BB vectorization analysis the defensive handling of external backedge defs in vect_get_and_check_slp_defs doesn't work since that relies on dominance info to identify a backedge. The testcase also shows we are iterating over the function in a sub-optimal way which is why we split the irreducible region in the first place. The fix is to mark backedges and use EDGE_DFS_BACK to identify them and to use the region RPO compute which can produce a RPO order keeping cycles in a better order (and as side effect marks backedges). PR tree-optimization/111387 * tree-vect-slp.cc (vect_get_and_check_slp_defs): Check EDGE_DFS_BACK when doing BB vectorization. (vect_slp_function): Use rev_post_order_and_mark_dfs_back_seme to compute RPO and mark backedges. * gcc.dg/torture/pr111387.c: New testcase.