aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vectorizer.h
diff options
context:
space:
mode:
authorFeng Xue <fxue@os.amperecomputing.com>2024-07-12 16:38:28 +0800
committerFeng Xue <fxue@os.amperecomputing.com>2024-07-17 21:54:05 +0800
commite7fbae834f8db2508d3161d88efe7ddbb702e437 (patch)
tree193a0f41c9c42cc8d2b43099a1069bfa80ab2904 /gcc/tree-vectorizer.h
parent24689b84b8ec0c74c2b9a72ec4fb467069806bda (diff)
downloadgcc-e7fbae834f8db2508d3161d88efe7ddbb702e437.zip
gcc-e7fbae834f8db2508d3161d88efe7ddbb702e437.tar.gz
gcc-e7fbae834f8db2508d3161d88efe7ddbb702e437.tar.bz2
vect: Add a unified vect_get_num_copies for slp and non-slp
Extend original vect_get_num_copies (pure loop-based) to calculate number of vector stmts for slp node regarding a generic vect region. 2024-07-12 Feng Xue <fxue@os.amperecomputing.com> gcc/ * tree-vectorizer.h (vect_get_num_copies): New overload function. * tree-vect-slp.cc (vect_slp_analyze_node_operations_1): Calculate number of vector stmts for slp node with vect_get_num_copies. (vect_slp_analyze_node_operations): Calculate number of vector elements for constant/external slp node with vect_get_num_copies.
Diffstat (limited to 'gcc/tree-vectorizer.h')
-rw-r--r--gcc/tree-vectorizer.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 8eb3ec4..1e2121a 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -2080,6 +2080,32 @@ vect_get_num_vectors (poly_uint64 nunits, tree vectype)
return exact_div (nunits, TYPE_VECTOR_SUBPARTS (vectype)).to_constant ();
}
+/* Return the number of vectors in the context of vectorization region VINFO,
+ needed for a group of statements, whose size is specified by lanes of NODE,
+ if NULL, it is 1. The statements are supposed to be interleaved together
+ with no gap, and all operate on vectors of type VECTYPE, if NULL, the
+ vectype of NODE is used. */
+
+inline unsigned int
+vect_get_num_copies (vec_info *vinfo, slp_tree node, tree vectype = NULL)
+{
+ poly_uint64 vf;
+
+ if (loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo))
+ vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
+ else
+ vf = 1;
+
+ if (node)
+ {
+ vf *= SLP_TREE_LANES (node);
+ if (!vectype)
+ vectype = SLP_TREE_VECTYPE (node);
+ }
+
+ return vect_get_num_vectors (vf, vectype);
+}
+
/* Return the number of copies needed for loop vectorization when
a statement operates on vectors of type VECTYPE. This is the
vectorization factor divided by the number of elements in
@@ -2088,7 +2114,7 @@ vect_get_num_vectors (poly_uint64 nunits, tree vectype)
inline unsigned int
vect_get_num_copies (loop_vec_info loop_vinfo, tree vectype)
{
- return vect_get_num_vectors (LOOP_VINFO_VECT_FACTOR (loop_vinfo), vectype);
+ return vect_get_num_copies (loop_vinfo, NULL, vectype);
}
/* Update maximum unit count *MAX_NUNITS so that it accounts for