https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116352
--- Comment #20 from GCC 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:5ab3f091b3eb42795340d3c9cea8aaec2060693c commit r15-5863-g5ab3f091b3eb42795340d3c9cea8aaec2060693c Author: Richard Biener <rguent...@suse.de> Date: Mon Dec 2 11:07:46 2024 +0100 tree-optimization/116352 - SLP scheduling and stmt order The PR uncovers unchecked constraints on the ability to code-generate with SLP but also latent issues with regard to stmt order checking since loop (early-break) and BB (for quite some time) vectorization are no longer constraint to single-BBs. In particular get_later_stmt simply compares UIDs of stmts, but that's only reliable when they are in the same BB. For the PR in question the problematical case is demoting a SLP node to external which fails to check we can actually code generate this in the way we do (using get_later_stmt). The following thus adds checking that we demote to external only when all defs are from the same BB. We no longer vectorize gcc.dg/vect/bb-slp-49.c but the testcase was for a wrong-code issue and the vectorization done is a no-op. PR tree-optimization/116352 PR tree-optimization/117876 * tree-vect-slp.cc (vect_slp_can_convert_to_external): New. (vect_slp_convert_to_external): Call it. (vect_build_slp_tree_2): Likewise. * gcc.dg/vect/pr116352.c: New testcase. * gcc.dg/vect/bb-slp-49.c: Remove vectorization check.