https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106794
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>: https://gcc.gnu.org/g:1005c89431cc78a68762643e1bc7249c3959927e commit r13-2738-g1005c89431cc78a68762643e1bc7249c3959927e Author: Richard Sandiford <richard.sandif...@arm.com> Date: Tue Sep 20 15:27:47 2022 +0100 vect: Fix SLP layout handling of masked loads [PR106794] PR106794 shows that I'd forgotten about masked loads when doing the SLP layout changes. These loads can't currently be permuted independently of their mask input, so during construction they never get a load permutation. (If we did support permuting masked loads in future, the mask would need to be in the right order for the load, rather than in the order implied by the result of the permutation. Since masked loads can't be partly or fully scalarised in the way that normal permuted loads can be, there's probably no benefit to fusing the permutation and the load. Permutation after the fact is probably good enough.) gcc/ PR tree-optimization/106794 PR tree-optimization/106914 * tree-vect-slp.cc (vect_optimize_slp_pass::internal_node_cost): Only consider loads that already have a permutation. (vect_optimize_slp_pass::start_choosing_layouts): Assert that loads with permutations are leaf nodes. Prevent any kind of grouped access from changing layout if it doesn't have a load permutation. gcc/testsuite/ * gcc.dg/vect/pr106914.c: New test. * g++.dg/vect/pr106794.cc: Likewise.