https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110221
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:7c67939ec384425a3d7383dfb4fb39aa7e9ad20a commit r13-8288-g7c67939ec384425a3d7383dfb4fb39aa7e9ad20a Author: Richard Biener <rguent...@suse.de> Date: Fri Nov 10 12:39:11 2023 +0100 tree-optimization/110221 - SLP and loop mask/len The following fixes the issue that when SLP stmts are internal defs but appear invariant because they end up only using invariant defs then they get scheduled outside of the loop. This nice optimization breaks down when loop masks or lens are applied since those are not explicitly tracked as dependences. The following makes sure to never schedule internal defs outside of the vectorized loop when the loop uses masks/lens. PR tree-optimization/110221 * tree-vect-slp.cc (vect_schedule_slp_node): When loop masking / len is applied make sure to not schedule intenal defs outside of the loop. * gfortran.dg/pr110221.f: New testcase. (cherry picked from commit e5f1956498251a4973d52c8aad3faf34d0443169)