diff options
author | Richard Biener <rguenther@suse.de> | 2023-11-06 12:43:11 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-11-06 14:06:01 +0100 |
commit | 3cc9ad41db87fb85b13a56bff1f930c258542a70 (patch) | |
tree | 84ce7033686d67f9fc8ec4de56ce4613a42a227f /gcc/tree-vect-loop.cc | |
parent | 9d1bf1d0b7a14ef741e967e0ab3ead35ec8e5f4e (diff) | |
download | gcc-3cc9ad41db87fb85b13a56bff1f930c258542a70.zip gcc-3cc9ad41db87fb85b13a56bff1f930c258542a70.tar.gz gcc-3cc9ad41db87fb85b13a56bff1f930c258542a70.tar.bz2 |
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.
Diffstat (limited to 'gcc/tree-vect-loop.cc')
-rw-r--r-- | gcc/tree-vect-loop.cc | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 362856a..5213aa0 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -2943,17 +2943,19 @@ start_over: != IFN_LAST) { FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (instance), i, load_node) - { - stmt_vec_info stmt_vinfo = DR_GROUP_FIRST_ELEMENT - (SLP_TREE_SCALAR_STMTS (load_node)[0]); - /* Use SLP for strided accesses (or if we can't - load-lanes). */ - if (STMT_VINFO_STRIDED_P (stmt_vinfo) - || vect_load_lanes_supported - (STMT_VINFO_VECTYPE (stmt_vinfo), - DR_GROUP_SIZE (stmt_vinfo), false) == IFN_LAST) - break; - } + if (STMT_VINFO_GROUPED_ACCESS + (SLP_TREE_REPRESENTATIVE (load_node))) + { + stmt_vec_info stmt_vinfo = DR_GROUP_FIRST_ELEMENT + (SLP_TREE_REPRESENTATIVE (load_node)); + /* Use SLP for strided accesses (or if we can't + load-lanes). */ + if (STMT_VINFO_STRIDED_P (stmt_vinfo) + || vect_load_lanes_supported + (STMT_VINFO_VECTYPE (stmt_vinfo), + DR_GROUP_SIZE (stmt_vinfo), false) == IFN_LAST) + break; + } can_use_lanes = can_use_lanes && i == SLP_INSTANCE_LOADS (instance).length (); @@ -3261,16 +3263,19 @@ again: "unsupported grouped store\n"); FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (instance), j, node) { - vinfo = SLP_TREE_SCALAR_STMTS (node)[0]; - vinfo = DR_GROUP_FIRST_ELEMENT (vinfo); - bool single_element_p = !DR_GROUP_NEXT_ELEMENT (vinfo); - size = DR_GROUP_SIZE (vinfo); - vectype = STMT_VINFO_VECTYPE (vinfo); - if (vect_load_lanes_supported (vectype, size, false) == IFN_LAST - && ! vect_grouped_load_supported (vectype, single_element_p, - size)) - return opt_result::failure_at (vinfo->stmt, - "unsupported grouped load\n"); + vinfo = SLP_TREE_REPRESENTATIVE (node); + if (STMT_VINFO_GROUPED_ACCESS (vinfo)) + { + vinfo = DR_GROUP_FIRST_ELEMENT (vinfo); + bool single_element_p = !DR_GROUP_NEXT_ELEMENT (vinfo); + size = DR_GROUP_SIZE (vinfo); + vectype = STMT_VINFO_VECTYPE (vinfo); + if (vect_load_lanes_supported (vectype, size, false) == IFN_LAST + && ! vect_grouped_load_supported (vectype, single_element_p, + size)) + return opt_result::failure_at (vinfo->stmt, + "unsupported grouped load\n"); + } } } |