tree-optimization/112404 - two issues with SLP of .MASK_LOAD
commit3cc9ad41db87fb85b13a56bff1f930c258542a70
authorRichard Biener <rguenther@suse.de>
Mon, 6 Nov 2023 11:43:11 +0000 (6 12:43 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 6 Nov 2023 13:06:01 +0000 (6 14:06 +0100)
tree84ce7033686d67f9fc8ec4de56ce4613a42a227f
parent9d1bf1d0b7a14ef741e967e0ab3ead35ec8e5f4e
tree-optimization/112404 - two issues with SLP of .MASK_LOAD

The following fixes an oversight in vect_check_scalar_mask when
the mask is external or constant.  When doing BB vectorization
we need to provide a group_size, best via an overload accepting
the SLP node as argument.

When fixed we then run into the issue that we have not analyzed
alignment of the .MASK_LOADs because they were not identified
as loads by vect_gather_slp_loads.  Fixed by reworking the
detection.

PR tree-optimization/112404
* tree-vectorizer.h (get_mask_type_for_scalar_type): Declare
overload with SLP node argument.
* tree-vect-stmts.cc (get_mask_type_for_scalar_type): Implement it.
(vect_check_scalar_mask): Use it.
* tree-vect-slp.cc (vect_gather_slp_loads): Properly identify
loads also for nodes with children, like .MASK_LOAD.
* tree-vect-loop.cc (vect_analyze_loop_2): Look at the
representative for load nodes and check whether it is a grouped
access before looking for load-lanes support.

* gfortran.dg/pr112404.f90: New testcase.
gcc/testsuite/gfortran.dg/pr112404.f90 [new file with mode: 0644]
gcc/tree-vect-loop.cc
gcc/tree-vect-slp.cc
gcc/tree-vect-stmts.cc
gcc/tree-vectorizer.h