From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id CC0753856962 for ; Tue, 15 Aug 2023 13:27:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC0753856962 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E767C2185D for ; Tue, 15 Aug 2023 13:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692106062; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=VglNfSJabgRoM3koalv8uaAZB794xA5f6Laoj8/eGVA=; b=1T2QsjWq3YbK9Evk89rBcoL5HLAhvlTfYm21FDOQSP/0GYCjJiKf5GU4l7FSzp+lwsjk6L ufIkhLmgtGm1ZBJezmbNbncGws+kM4vOVhTpRDrfT4rv5YCBQ650WotXADKAM97xAGFkUj Ml3Z9ssle0cJYM9Xjr7G7+Sm7FeuM9s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692106062; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=VglNfSJabgRoM3koalv8uaAZB794xA5f6Laoj8/eGVA=; b=ktHVqPqshvFXBv/zS8L+/RdDydJcgBujsZKsUsjRfV8SeQZbfP8foBOYod44oapQZD2Lw0 B0fAxsZEE5KKG7Aw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id D5C692C146 for ; Tue, 15 Aug 2023 13:27:42 +0000 (UTC) Date: Tue, 15 Aug 2023 13:27:42 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Cleanup BB vectorization roots handling User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,MISSING_MID,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20230815132742.J4KYCCEkn1tL3YbzdYyEWNLbjf1QQxDP3DLkeIm4IRI@z> The following moves CONSTRUCTOR handling into the generic BB vectorization roots handling, removing a special case and finally renaming the function now consisting of more than just constructor detection. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-vect-slp.cc (vect_analyze_slp_instance): Remove slp_inst_kind_ctor handling. (vect_analyze_slp): Simplify. (vect_build_slp_instance): Dump when we analyze a CTOR. (vect_slp_check_for_constructors): Rename to ... (vect_slp_check_for_roots): ... this. Register a slp_root for CONSTRUCTORs instead of shoving them to the set of grouped stores. (vect_slp_analyze_bb_1): Adjust. --- gcc/tree-vect-slp.cc | 56 ++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 40514e4758d..0563684928e 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -3123,6 +3123,14 @@ vect_build_slp_instance (vec_info *vinfo, /* ??? We need stmt_info for group splitting. */ stmt_vec_info stmt_info_) { + if (kind == slp_inst_kind_ctor) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "Analyzing vectorizable constructor: %G\n", + root_stmt_infos[0]->stmt); + } + if (dump_enabled_p ()) { dump_printf_loc (MSG_NOTE, vect_location, @@ -3429,22 +3437,6 @@ vect_analyze_slp_instance (vec_info *vinfo, STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info)) = STMT_VINFO_REDUC_DEF (vect_orig_stmt (scalar_stmts.last ())); } - else if (kind == slp_inst_kind_ctor) - { - tree rhs = gimple_assign_rhs1 (stmt_info->stmt); - tree val; - scalar_stmts.create (CONSTRUCTOR_NELTS (rhs)); - FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), i, val) - { - stmt_vec_info def_info = vinfo->lookup_def (val); - def_info = vect_stmt_to_vectorize (def_info); - scalar_stmts.quick_push (def_info); - } - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "Analyzing vectorizable constructor: %G\n", - stmt_info->stmt); - } else if (kind == slp_inst_kind_reduc_group) { /* Collect reduction statements. */ @@ -3469,19 +3461,12 @@ vect_analyze_slp_instance (vec_info *vinfo, vec roots = vNULL; vec remain = vNULL; - if (kind == slp_inst_kind_ctor) - { - roots.create (1); - roots.quick_push (stmt_info); - } /* Build the tree for the SLP instance. */ bool res = vect_build_slp_instance (vinfo, kind, scalar_stmts, roots, remain, max_tree_size, limit, bst_map, kind == slp_inst_kind_store ? stmt_info : NULL); - if (!res) - roots.release (); /* ??? If this is slp_inst_kind_store and the above succeeded here's where we should do store group splitting. */ @@ -3509,9 +3494,7 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) /* Find SLP sequences starting from groups of grouped stores. */ FOR_EACH_VEC_ELT (vinfo->grouped_stores, i, first_element) vect_analyze_slp_instance (vinfo, bst_map, first_element, - STMT_VINFO_GROUPED_ACCESS (first_element) - ? slp_inst_kind_store : slp_inst_kind_ctor, - max_tree_size, &limit); + slp_inst_kind_store, max_tree_size, &limit); if (bb_vec_info bb_vinfo = dyn_cast (vinfo)) { @@ -7106,7 +7089,7 @@ vect_slp_is_lane_insert (gimple *use_stmt, tree vec, unsigned *this_lane) array. */ static void -vect_slp_check_for_constructors (bb_vec_info bb_vinfo) +vect_slp_check_for_roots (bb_vec_info bb_vinfo) { for (unsigned i = 0; i < bb_vinfo->bbs.length (); ++i) for (gimple_stmt_iterator gsi = gsi_start_bb (bb_vinfo->bbs[i]); @@ -7132,14 +7115,21 @@ vect_slp_check_for_constructors (bb_vec_info bb_vinfo) unsigned j; tree val; FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), j, val) - if (TREE_CODE (val) != SSA_NAME - || !bb_vinfo->lookup_def (val)) - break; + if (TREE_CODE (val) != SSA_NAME + || !bb_vinfo->lookup_def (val)) + break; if (j != CONSTRUCTOR_NELTS (rhs)) continue; - stmt_vec_info stmt_info = bb_vinfo->lookup_stmt (assign); - BB_VINFO_GROUPED_STORES (bb_vinfo).safe_push (stmt_info); + vec roots = vNULL; + roots.safe_push (bb_vinfo->lookup_stmt (assign)); + vec stmts; + stmts.create (CONSTRUCTOR_NELTS (rhs)); + FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), j, val) + stmts.quick_push + (vect_stmt_to_vectorize (bb_vinfo->lookup_def (val))); + bb_vinfo->roots.safe_push (slp_root (slp_inst_kind_ctor, + stmts, roots)); } else if (code == BIT_INSERT_EXPR && VECTOR_TYPE_P (TREE_TYPE (rhs)) @@ -7405,7 +7395,7 @@ vect_slp_analyze_bb_1 (bb_vec_info bb_vinfo, int n_stmts, bool &fatal, return false; } - vect_slp_check_for_constructors (bb_vinfo); + vect_slp_check_for_roots (bb_vinfo); /* If there are no grouped stores and no constructors in the region there is no need to continue with pattern recog as vect_analyze_slp -- 2.35.3