From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 3EB853858D1E for ; Thu, 13 Jul 2023 16:23:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3EB853858D1E 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 imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2553322151; Thu, 13 Jul 2023 16:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689265384; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XFWrCfIvbMumn+RidxvkaXqLxd2fE56J3dufIyjxiCQ=; b=yg6upacV38mo7kTKtsDIiV+k4GLWaef83gY3cEao0fQ7iQuvcrcK+mZBgnB8Aiz2XgnGE0 PLJSIcf/EDolMpXwFigteHyr7j6nEyM2Zagnri0zXLMrRqQ+dhrkAxZ7hADLVSHbraQxef Vz8F+TTZStn87AeFOcdV87QlvRjUMd8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689265384; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XFWrCfIvbMumn+RidxvkaXqLxd2fE56J3dufIyjxiCQ=; b=WMCVRiJN292J1hxKKglJJGwQgJdP44i0lCQm+PX8asx3qYzeAbWNzBnwzamY0J49CpShij KRuLmBZ+SdYzowAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 03BAD13489; Thu, 13 Jul 2023 16:23:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yJNAO+cksGTvQAAAMHmgww (envelope-from ); Thu, 13 Jul 2023 16:23:03 +0000 Date: Thu, 13 Jul 2023 18:23:03 +0200 (CEST) From: Richard Biener To: Tamar Christina cc: "gcc-patches@gcc.gnu.org" , nd , "jlaw@ventanamicro.com" Subject: RE: [PATCH 9/19] middle-end: refactor vectorizable_comparison to make the main body re-usable. In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: On Wed, 28 Jun 2023, Tamar Christina wrote: > Adding proper maintainers. > > > -----Original Message----- > > From: Tamar Christina > > Sent: Wednesday, June 28, 2023 2:46 PM > > To: gcc-patches@gcc.gnu.org > > Cc: nd ; Richard Earnshaw ; > > Marcus Shawcroft ; Kyrylo Tkachov > > ; Richard Sandiford > > > > Subject: [PATCH 9/19]AArch64 middle-end: refactor vectorizable_comparison > > to make the main body re-usable. > > > > Hi All, > > > > Vectorization of a gcond starts off essentially the same as vectorizing a > > comparison witht he only difference being how the operands are extracted. > > > > This refactors vectorable_comparison such that we now have a generic > > function that can be used from vectorizable_early_break. The refactoring > > splits the gassign checks and actual validation/codegen off to a helper > > function. > > > > No change in functionality expected. > > > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > > > Ok for master? > > > > Thanks, > > Tamar > > > > gcc/ChangeLog: > > > > * tree-vect-stmts.cc (vectorizable_comparison): Refactor, splitting > > body > > to ... > > (vectorizable_comparison_1): ...This. > > > > --- inline copy of patch -- > > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index > > ae24f3e66e63d9bd9763284a47fb2c911335c4c1..f3e33cd4ed125b9564ca8 > > 1acd197693fc3457c31 100644 > > --- a/gcc/tree-vect-stmts.cc > > +++ b/gcc/tree-vect-stmts.cc > > @@ -11332,21 +11332,22 @@ vectorizable_condition (vec_info *vinfo, > > > > /* vectorizable_comparison. > > > > - Check if STMT_INFO is comparison expression that can be vectorized. > > +/* Helper of vectorizable_comparison. > > + > > + Check if STMT_INFO is comparison expression CODE that can be vectorized. > > If VEC_STMT is also passed, vectorize STMT_INFO: create a vectorized > > comparison, put it in VEC_STMT, and insert it at GSI. > > > > Return true if STMT_INFO is vectorizable in this way. */ > > > > static bool > > -vectorizable_comparison (vec_info *vinfo, > > - stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, > > - gimple **vec_stmt, > > - slp_tree slp_node, stmt_vector_for_cost *cost_vec) > > +vectorizable_comparison_1 (vec_info *vinfo, tree vectype, > > + stmt_vec_info stmt_info, tree_code code, > > + gimple_stmt_iterator *gsi, gimple **vec_stmt, > > + slp_tree slp_node, stmt_vector_for_cost *cost_vec) > > { > > tree lhs, rhs1, rhs2; > > tree vectype1 = NULL_TREE, vectype2 = NULL_TREE; > > - tree vectype = STMT_VINFO_VECTYPE (stmt_info); > > tree vec_rhs1 = NULL_TREE, vec_rhs2 = NULL_TREE; > > tree new_temp; > > loop_vec_info loop_vinfo = dyn_cast (vinfo); @@ -11354,7 > > +11355,7 @@ vectorizable_comparison (vec_info *vinfo, > > int ndts = 2; > > poly_uint64 nunits; > > int ncopies; > > - enum tree_code code, bitop1 = NOP_EXPR, bitop2 = NOP_EXPR; > > + enum tree_code bitop1 = NOP_EXPR, bitop2 = NOP_EXPR; > > int i; > > bb_vec_info bb_vinfo = dyn_cast (vinfo); > > vec vec_oprnds0 = vNULL; > > @@ -11377,14 +11378,6 @@ vectorizable_comparison (vec_info *vinfo, > > ncopies = vect_get_num_copies (loop_vinfo, vectype); > > > > gcc_assert (ncopies >= 1); > > - if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_internal_def) > > - return false; > > - > > - gassign *stmt = dyn_cast (stmt_info->stmt); > > - if (!stmt) > > - return false; > > - > > - code = gimple_assign_rhs_code (stmt); > > > > if (TREE_CODE_CLASS (code) != tcc_comparison) > > return false; > > @@ -11499,7 +11492,6 @@ vectorizable_comparison (vec_info *vinfo, > > return false; > > } > > > > - STMT_VINFO_TYPE (stmt_info) = comparison_vec_info_type; > > vect_model_simple_cost (vinfo, stmt_info, > > ncopies * (1 + (bitop2 != NOP_EXPR)), > > dts, ndts, slp_node, cost_vec); @@ -11565,6 > > +11557,44 @@ vectorizable_comparison (vec_info *vinfo, > > return true; > > } > > > > +/* vectorizable_comparison. > > + > > + Check if STMT_INFO is comparison expression that can be vectorized. > > + If VEC_STMT is also passed, vectorize STMT_INFO: create a vectorized > > + comparison, put it in VEC_STMT, and insert it at GSI. > > + > > + Return true if STMT_INFO is vectorizable in this way. */ > > + > > +static bool > > +vectorizable_comparison (vec_info *vinfo, > > + stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, > > + gimple **vec_stmt, > > + slp_tree slp_node, stmt_vector_for_cost *cost_vec) { { to the next line > > + bb_vec_info bb_vinfo = dyn_cast (vinfo); > > + > > + if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo) > > + return false; > > + > > + if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_internal_def) > > + return false; > > + > > + gassign *stmt = dyn_cast (stmt_info->stmt); if (!stmt) > > + return false; new line before 'if' otherwise OK. Thanks, Richard. > > + enum tree_code code = gimple_assign_rhs_code (stmt); > > + tree vectype = STMT_VINFO_VECTYPE (stmt_info); > > + if (!vectorizable_comparison_1 (vinfo, vectype, stmt_info, code, gsi, > > + vec_stmt, slp_node, cost_vec)) > > + return false; > > + > > + if (!vec_stmt) > > + STMT_VINFO_TYPE (stmt_info) = comparison_vec_info_type; > > + > > + return true; > > +} > > + > > /* If SLP_NODE is nonnull, return true if vectorizable_live_operation > > can handle all live statements in the node. Otherwise return true > > if STMT_INFO is not live or if vectorizable_live_operation can handle it. > > > > > > > > > > -- > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)