Hi Richi,
on 2020/3/25 下午4:25, Richard Biener wrote:
> On Tue, Mar 24, 2020 at 9:30 AM Kewen.Lin wrote:
>>
>> Hi,
>>
>> The new version with refactoring has been attached.
>> Bootstrapped/regtested on powerpc64le-linux-gnu (LE) P8 and P9.
>>
>> Is it ok for trunk?
>
> Yes.
>
Thanks! I'm sorry that I forgot to update the nelts with new element number
for smaller vector for the path constructing with smaller vectors.
The difference against the previous one is:
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -2251,12 +2251,13 @@ vector_vector_composition_type (tree vtype, poly_uint64
nelts, tree *ptype)
/* First check if vec_init optab supports construction from
vector pieces directly. */
scalar_mode elmode = SCALAR_TYPE_MODE (TREE_TYPE (vtype));
+ poly_uint64 inelts = pbsize / GET_MODE_BITSIZE (elmode);
machine_mode rmode;
- if (related_vector_mode (vmode, elmode, nelts).exists ()
+ if (related_vector_mode (vmode, elmode, inelts).exists ()
&& (convert_optab_handler (vec_init_optab, vmode, rmode)
!= CODE_FOR_nothing))
{
- *ptype = build_vector_type (TREE_TYPE (vtype), nelts);
+ *ptype = build_vector_type (TREE_TYPE (vtype), inelts);
return vtype;
}
This new version has been bootstrapped/regtested on
powerpc64le-linux-gnu (LE) P8 and x86_64-redhat-linux.
May I install this new instead?
BR,
Kewen
-
gcc/ChangeLog
2020-MM-DD Kewen Lin
PR tree-optimization/90332
* gcc/tree-vect-stmts.c (vector_vector_composition_type): New function.
(get_group_load_store_type): Adjust to call
vector_vector_composition_type,
extend it to construct with scalar types.
(vectorizable_load): Likewise.
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 2ca8e494680..12beef6978c 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -2220,6 +2220,62 @@ vect_get_store_rhs (stmt_vec_info stmt_info)
gcc_unreachable ();
}
+/* Function VECTOR_VECTOR_COMPOSITION_TYPE
+
+ This function returns a vector type which can be composed with NETLS pieces,
+ whose type is recorded in PTYPE. VTYPE should be a vector type, and has the
+ same vector size as the return vector. It checks target whether supports
+ pieces-size vector mode for construction firstly, if target fails to, check
+ pieces-size scalar mode for construction further. It returns NULL_TREE if
+ fails to find the available composition.
+
+ For example, for (vtype=V16QI, nelts=4), we can probably get:
+ - V16QI with PTYPE V4QI.
+ - V4SI with PTYPE SI.
+ - NULL_TREE. */
+
+static tree
+vector_vector_composition_type (tree vtype, poly_uint64 nelts, tree *ptype)
+{
+ gcc_assert (VECTOR_TYPE_P (vtype));
+ gcc_assert (known_gt (nelts, 0U));
+
+ machine_mode vmode = TYPE_MODE (vtype);
+ if (!VECTOR_MODE_P (vmode))
+return NULL_TREE;
+
+ poly_uint64 vbsize = GET_MODE_BITSIZE (vmode);
+ unsigned int pbsize;
+ if (constant_multiple_p (vbsize, nelts, ))
+{
+ /* First check if vec_init optab supports construction from
+vector pieces directly. */
+ scalar_mode elmode = SCALAR_TYPE_MODE (TREE_TYPE (vtype));
+ poly_uint64 inelts = pbsize / GET_MODE_BITSIZE (elmode);
+ machine_mode rmode;
+ if (related_vector_mode (vmode, elmode, inelts).exists ()
+ && (convert_optab_handler (vec_init_optab, vmode, rmode)
+ != CODE_FOR_nothing))
+ {
+ *ptype = build_vector_type (TREE_TYPE (vtype), inelts);
+ return vtype;
+ }
+
+ /* Otherwise check if exists an integer type of the same piece size and
+if vec_init optab supports construction from it directly. */
+ if (int_mode_for_size (pbsize, 0).exists ()
+ && related_vector_mode (vmode, elmode, nelts).exists ()
+ && (convert_optab_handler (vec_init_optab, rmode, elmode)
+ != CODE_FOR_nothing))
+ {
+ *ptype = build_nonstandard_integer_type (pbsize, 1);
+ return build_vector_type (*ptype, nelts);
+ }
+}
+
+ return NULL_TREE;
+}
+
/* A subroutine of get_load_store_type, with a subset of the same
arguments. Handle the case where STMT_INFO is part of a grouped load
or store.
@@ -2300,8 +2356,7 @@ get_group_load_store_type (stmt_vec_info stmt_info, tree
vectype, bool slp,
by simply loading half of the vector only. Usually
the construction with an upper zero half will be elided. */
dr_alignment_support alignment_support_scheme;
- scalar_mode elmode = SCALAR_TYPE_MODE (TREE_TYPE (vectype));
- machine_mode vmode;
+ tree half_vtype;
if (overrun_p
&& !masked_p
&& (((alignment_support_scheme
@@ -2310,12 +2365,8 @@ get_group_load_store_type (stmt_vec_info stmt_info, tree
vectype, bool slp,
|| alignment_support_scheme ==