https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119960
--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-15 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:8fb3d9066266ea30de62c395239bda4e992297a3 commit r15-9782-g8fb3d9066266ea30de62c395239bda4e992297a3 Author: Richard Biener <rguent...@suse.de> Date: Tue Apr 29 13:23:41 2025 +0200 tree-optimization/119960 - failed external SLP promotion The following addresses a too conservative sanity check of SLP nodes we want to promote external. The issue lies in code generation for such external which relies on get_later_stmt to figure an insert location. But get_later_stmt relies on the ability to totally order stmts, specifically implementation-wise that they are all from the same BB, which is what is verified at the moment. The patch changes this to require stmts to be orderable by dominance queries. For simplicity and seemingly enough for the testcase in PR119960, this handles the case of two distinct BBs. PR tree-optimization/119960 * tree-vect-slp.cc (vect_slp_can_convert_to_external): Handle cases where defs from multiple BBs are ordered by their dominance relation. * gcc.dg/vect/bb-slp-pr119960-1.c: New testcase. (cherry picked from commit cc74e2f2b39b6debbef1787a087abad2108e95dd)