random vectorizer fixes

This fixes random things found when doing SLP discovery from
arbitrary sets of stmts.

2020-09-10  Richard Biener  <rguenther@suse.de>

	* tree-vect-slp.c (vect_build_slp_tree_1): Check vector
	types for all lanes are compatible.
	(vect_analyze_slp_instance): Appropriately check for stores.
	(vect_schedule_slp): Likewise.
This commit is contained in:
Richard Biener 2020-09-10 16:23:29 +02:00
parent 5e044c673f
commit 563326b5e4

View file

@ -1007,6 +1007,16 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
continue;
}
}
if (!types_compatible_p (vectype, *node_vectype))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
"Build SLP failed: different vector type "
"in %G", stmt);
/* Mismatch. */
continue;
}
}
/* Grouped store or load. */
@ -2382,7 +2392,7 @@ vect_analyze_slp_instance (vec_info *vinfo,
unsigned HOST_WIDE_INT const_nunits;
if (is_a <bb_vec_info> (vinfo)
&& STMT_VINFO_GROUPED_ACCESS (stmt_info)
&& DR_GROUP_FIRST_ELEMENT (stmt_info)
&& DR_IS_WRITE (STMT_VINFO_DATA_REF (stmt_info))
&& nunits.is_constant (&const_nunits))
{
/* We consider breaking the group only on VF boundaries from the existing
@ -4893,14 +4903,13 @@ vect_schedule_slp (vec_info *vinfo)
if (is_a <loop_vec_info> (vinfo))
vect_remove_slp_scalar_calls (vinfo, root);
/* Remove vectorized stores original scalar stmts. */
for (j = 0; SLP_TREE_SCALAR_STMTS (root).iterate (j, &store_info); j++)
{
if (!STMT_VINFO_DATA_REF (store_info))
if (!STMT_VINFO_DATA_REF (store_info)
|| !DR_IS_WRITE (STMT_VINFO_DATA_REF (store_info)))
break;
if (SLP_INSTANCE_ROOT_STMT (instance))
continue;
store_info = vect_orig_stmt (store_info);
/* Free the attached stmt_vec_info and remove the stmt. */
vinfo->remove_stmt (store_info);