From: Richard Biener Date: Mon, 16 Nov 2020 13:26:20 +0000 (+0100) Subject: Delay SLP instance loads gathering X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c84df34aec3bb845b22384c7e85f0449ca00dd99;p=gcc.git Delay SLP instance loads gathering This delays filling SLP_INSTANCE_LOADS. 2020-11-16 Richard Biener * tree-vectorizer.h (vect_gather_slp_loads): Declare. * tree-vect-loop.c (vect_analyze_loop_2): Call vect_gather_slp_loads. * tree-vect-slp.c (vect_build_slp_instance): Do not gather SLP loads here. (vect_gather_slp_loads): Remove wrapper, new function. (vect_slp_analyze_bb_1): Call it. --- diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 4d5532f71d0..ecaaf0116d3 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -2298,6 +2298,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal, unsigned *n_stmts) /* Optimize the SLP graph with the vectorization factor fixed. */ vect_optimize_slp (loop_vinfo); + + /* Gather the loads reachable from the SLP graph entries. */ + vect_gather_slp_loads (loop_vinfo); } bool saved_can_use_partial_vectors_p diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index b98d5db9f76..d2f2407ac92 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2071,13 +2071,6 @@ vect_gather_slp_loads (vec &loads, slp_tree node, } } -static void -vect_gather_slp_loads (slp_instance inst, slp_tree node) -{ - hash_set visited; - vect_gather_slp_loads (SLP_INSTANCE_LOADS (inst), node, visited); -} - /* Find the last store in SLP INSTANCE. */ @@ -2252,7 +2245,6 @@ vect_build_slp_instance (vec_info *vinfo, new_instance->cost_vec = vNULL; new_instance->subgraph_entries = vNULL; - vect_gather_slp_loads (new_instance, node); if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "SLP size %u vs. limit %u.\n", @@ -3071,6 +3063,21 @@ vect_optimize_slp (vec_info *vinfo) } } +/* Gather loads reachable from the individual SLP graph entries. */ + +void +vect_gather_slp_loads (vec_info *vinfo) +{ + unsigned i; + slp_instance instance; + FOR_EACH_VEC_ELT (vinfo->slp_instances, i, instance) + { + hash_set visited; + vect_gather_slp_loads (SLP_INSTANCE_LOADS (instance), + SLP_INSTANCE_TREE (instance), visited); + } +} + /* For each possible SLP instance decide whether to SLP it and calculate overall unrolling factor needed to SLP the loop. Return TRUE if decided to SLP at @@ -4152,6 +4159,9 @@ vect_slp_analyze_bb_1 (bb_vec_info bb_vinfo, int n_stmts, bool &fatal, /* Optimize permutations. */ vect_optimize_slp (bb_vinfo); + /* Gather the loads reachable from the SLP graph entries. */ + vect_gather_slp_loads (bb_vinfo); + vect_record_base_alignments (bb_vinfo); /* Analyze and verify the alignment of data references and the diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 3ccd0fd552d..0ee4ef32eb2 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1974,6 +1974,7 @@ extern opt_result vect_analyze_slp (vec_info *, unsigned); extern bool vect_make_slp_decision (loop_vec_info); extern void vect_detect_hybrid_slp (loop_vec_info); extern void vect_optimize_slp (vec_info *); +extern void vect_gather_slp_loads (vec_info *); extern void vect_get_slp_defs (slp_tree, vec *); extern void vect_get_slp_defs (vec_info *, slp_tree, vec > *, unsigned n = -1U);