https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107451
--- Comment #11 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:7b2cf5041460859ca4f58e5da1308b7ef9129d8b commit r13-4843-g7b2cf5041460859ca4f58e5da1308b7ef9129d8b Author: Richard Biener <rguent...@suse.de> Date: Thu Dec 22 09:36:17 2022 +0100 tree-optimization/107451 - SLP load vectorization issue When vectorizing SLP loads with permutations we can access excess elements when the load vector type is bigger than the group size and the vectorization factor covers less groups than necessary to fill it. Since we know the code will only access up to group_size * VF elements in the unpermuted vector we can simply fill the rest of the vector with whatever we want. For simplicity this patch chooses to repeat the last group. PR tree-optimization/107451 * tree-vect-stmts.cc (vectorizable_load): Avoid loading SLP group members from group numbers in excess of the vectorization factor. * gcc.dg/torture/pr107451.c: New testcase.