From 563326b5e49fcaace2fcab2ddd4071a5f1cfe709 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 10 Sep 2020 16:23:29 +0200 Subject: [PATCH] random vectorizer fixes This fixes random things found when doing SLP discovery from arbitrary sets of stmts. 2020-09-10 Richard Biener * 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. --- gcc/tree-vect-slp.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 458a2c5bb30..aa6aa3328e8 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -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 (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 (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); -- 2.30.2