The strided-store path needs to have the SLP trees vector type so
the following patch passes dowm the vector type to be used to
vect_check_gather_scatter and adjusts all other callers. This
removes one of the last pieces requiring STMT_VINFO_VECTYPE
during SLP stmt analysis.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
* tree-vectorizer.h (vect_check_gather_scatter): Add
vectype parameter.
* tree-vect-data-refs.cc (vect_check_gather_scatter): Get
vectype as parameter.
(vect_analyze_data_refs): Adjust.
* tree-vect-patterns.cc (vect_recog_gather_scatter_pattern): Likewise.
* tree-vect-slp.cc (vect_get_and_check_slp_defs): Get vectype
as parameter, pass down.
(vect_build_slp_tree_2): Adjust.
* tree-vect-stmts.cc (vect_mark_stmts_to_be_vectorized): Likewise.
(vect_use_strided_gather_scatters_p): Likewise.
---
gcc/tree-vect-data-refs.cc | 12 ++++++------
gcc/tree-vect-patterns.cc | 10 +++++-----
gcc/tree-vect-slp.cc | 7 ++++---
gcc/tree-vect-stmts.cc | 7 +++++--
gcc/tree-vectorizer.h | 4 ++--
5 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index f9bf6a21697..1395776599a 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -4554,12 +4554,13 @@ vect_describe_gather_scatter_call (stmt_vec_info
stmt_info,
}
/* Return true if a non-affine read or write in STMT_INFO is suitable for a
- gather load or scatter store. Describe the operation in *INFO if so.
- If it is suitable and ELSVALS is nonzero store the supported else values
- in the vector it points to. */
+ gather load or scatter store with VECTYPE. Describe the operation in *INFO
+ if so. If it is suitable and ELSVALS is nonzero store the supported else
+ values in the vector it points to. */
bool
-vect_check_gather_scatter (stmt_vec_info stmt_info, loop_vec_info loop_vinfo,
+vect_check_gather_scatter (stmt_vec_info stmt_info, tree vectype,
+ loop_vec_info loop_vinfo,
gather_scatter_info *info, vec<int> *elsvals)
{
HOST_WIDE_INT scale = 1;
@@ -4568,7 +4569,6 @@ vect_check_gather_scatter (stmt_vec_info stmt_info,
loop_vec_info loop_vinfo,
struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info);
tree offtype = NULL_TREE;
tree decl = NULL_TREE, base, off;
- tree vectype = STMT_VINFO_VECTYPE (stmt_info);
tree memory_type = TREE_TYPE (DR_REF (dr));
machine_mode pmode;
int punsignedp, reversep, pvolatilep = 0;
@@ -5273,7 +5273,7 @@ vect_analyze_data_refs (vec_info *vinfo, bool *fatal)
if (gatherscatter != SG_NONE)
{
gather_scatter_info gs_info;
- if (!vect_check_gather_scatter (stmt_info,
+ if (!vect_check_gather_scatter (stmt_info, vectype,
as_a <loop_vec_info> (vinfo),
&gs_info)
|| !get_vectype_for_scalar_type (vinfo,
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 9f3cc65d215..3b2f2a2174c 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -6028,16 +6028,17 @@ vect_recog_gather_scatter_pattern (vec_info *vinfo,
This is null if the operation is unconditional. */
tree mask = vect_get_load_store_mask (stmt_info);
+ /* DR analysis nailed down the vector type for the access. */
+ tree gs_vectype = STMT_VINFO_VECTYPE (stmt_info);
+
/* Make sure that the target supports an appropriate internal
function for the gather/scatter operation. */
gather_scatter_info gs_info;
- if (!vect_check_gather_scatter (stmt_info, loop_vinfo, &gs_info)
+ if (!vect_check_gather_scatter (stmt_info, gs_vectype, loop_vinfo, &gs_info)
|| gs_info.ifn == IFN_LAST)
return NULL;
/* Convert the mask to the right form. */
- tree gs_vectype = get_vectype_for_scalar_type (loop_vinfo,
- gs_info.element_type);
if (mask)
mask = vect_convert_mask_for_vectype (mask, gs_vectype, stmt_info,
loop_vinfo);
@@ -6099,8 +6100,7 @@ vect_recog_gather_scatter_pattern (vec_info *vinfo,
stmt_vec_info pattern_stmt_info = loop_vinfo->add_stmt (pattern_stmt);
loop_vinfo->move_dr (pattern_stmt_info, stmt_info);
- tree vectype = STMT_VINFO_VECTYPE (stmt_info);
- *type_out = vectype;
+ *type_out = gs_vectype;
vect_pattern_detected ("gather/scatter pattern", stmt_info->stmt);
return pattern_stmt;
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 5236eac5a42..6258a8eb53d 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -641,7 +641,7 @@ vect_slp_child_index_for_operand (const gimple *stmt, int
op,
swapping operands of father node of this one, return 1; if everything is
ok return 0. */
static int
-vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char swap,
+vect_get_and_check_slp_defs (vec_info *vinfo, tree vectype, unsigned char swap,
bool *skip_args,
vec<stmt_vec_info> stmts, unsigned stmt_num,
vec<slp_oprnd_info> *oprnds_info)
@@ -711,7 +711,7 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char
swap,
{
gcc_assert (STMT_VINFO_GATHER_SCATTER_P (stmt_info));
if (!is_a <loop_vec_info> (vinfo)
- || !vect_check_gather_scatter (stmt_info,
+ || !vect_check_gather_scatter (stmt_info, vectype,
as_a <loop_vec_info> (vinfo),
first ? &oprnd_info->first_gs_info
: &gs_info))
@@ -2618,7 +2618,8 @@ out:
slp_oprnd_info oprnd_info;
FOR_EACH_VEC_ELT (stmts, i, stmt_info)
{
- int res = vect_get_and_check_slp_defs (vinfo, swap[i], skip_args,
+ int res = vect_get_and_check_slp_defs (vinfo, vectype,
+ swap[i], skip_args,
stmts, i, &oprnds_info);
if (res != 0)
matches[(res == -1) ? 0 : i] = false;
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 8bc325176a3..7435add077e 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -891,7 +891,9 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo,
bool *fatal)
if (STMT_VINFO_GATHER_SCATTER_P (stmt_vinfo))
{
gather_scatter_info gs_info;
- if (!vect_check_gather_scatter (stmt_vinfo, loop_vinfo, &gs_info))
+ if (!vect_check_gather_scatter (stmt_vinfo,
+ STMT_VINFO_VECTYPE (stmt_vinfo),
+ loop_vinfo, &gs_info))
gcc_unreachable ();
opt_result res
= process_use (stmt_vinfo, gs_info.offset, loop_vinfo, relevant,
@@ -1738,7 +1740,8 @@ vect_use_strided_gather_scatters_p (stmt_vec_info
stmt_info, tree vectype,
unsigned int group_size,
bool single_element_p)
{
- if (!vect_check_gather_scatter (stmt_info, loop_vinfo, gs_info, elsvals)
+ if (!vect_check_gather_scatter (stmt_info, vectype,
+ loop_vinfo, gs_info, elsvals)
|| gs_info->ifn == IFN_LAST)
{
if (!vect_truncate_gather_scatter_offset (stmt_info, vectype, loop_vinfo,
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 250877734e4..e91e737ae6b 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -2621,8 +2621,8 @@ extern opt_result vect_prune_runtime_alias_test_list
(loop_vec_info);
extern bool vect_gather_scatter_fn_p (vec_info *, bool, bool, tree, tree,
tree, int, internal_fn *, tree *,
vec<int> * = nullptr);
-extern bool vect_check_gather_scatter (stmt_vec_info, loop_vec_info,
- gather_scatter_info *,
+extern bool vect_check_gather_scatter (stmt_vec_info, tree,
+ loop_vec_info, gather_scatter_info *,
vec<int> * = nullptr);
extern void vect_describe_gather_scatter_call (stmt_vec_info,
gather_scatter_info *);
--
2.43.0