vect: Fix SLP layout handling of masked loads [PR106794]
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 20 Sep 2022 14:27:47 +0000 (15:27 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 20 Sep 2022 14:27:47 +0000 (15:27 +0100)
commit1005c89431cc78a68762643e1bc7249c3959927e
treef877af71a0131d84dc6134c289ea2020ae71f20b
parent4a773bf2f08656a39ac75cf6b4871c8cec8b5007
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.
gcc/testsuite/g++.dg/vect/pr106794.cc [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr106914.c [new file with mode: 0644]
gcc/tree-vect-slp.cc