From patchwork Wed Dec 13 12:30:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 82048 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E8BD9385E02B for ; Wed, 13 Dec 2023 12:32:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id D39A63858C78 for ; Wed, 13 Dec 2023 12:31:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D39A63858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D39A63858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702470718; cv=none; b=SasaEdlpzWM4uT37SVCWkLLfHtiZN/9fO/x+zaejdl6RtcoIHKpFIt8Jev4VyD4/cWFQ/9wmzO83nxVmbGYNXNxKZtwQ0WVx8hubK23ou7ovo0go/d0TIfYMXfs74jWxUxwhrNsOk5bndsr9z/NGj9t8r6ABIRcOFqeFqGGmzsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702470718; c=relaxed/simple; bh=dnmWxz4adjCr+94DbArPnY0bhNrXUw1fLCD6pyZZD3Y=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=v+G1AJ92N9XxMxbWpzXPxPU15eocJ512IgX45WMGc3o83sPqmlLUJHIH4rgKcARmi1y7ROz7kzE2lMUUJOvUyrDZki1sO/8+GDvgPP6vlYSWKx+o1L5M7JTS6kGxlMvCukdugYLiS/XOEmXG1KwveH1FbUe2tCZIp2uDElCxNT0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BB408221C9 for ; Wed, 13 Dec 2023 12:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702470715; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=9n4M7ojf975L20RESRcujrAHYf0j3fGmQk2any59nC4=; b=m7vg46Gpj3t9z4z1ZFRDMK/A8ADUuwRzTxnhA0PKupUn0oHpmyYulgf+VeNFLQtFk9AWz0 dFA+oW8FQorrbD2Du75CQGRyrqpK0SwRCrReeSxcP1esE/nDQU0mVtA7d91447wWVnL14l B7wFcifALnFypUHRZB2WsUrroLtpfmU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702470715; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=9n4M7ojf975L20RESRcujrAHYf0j3fGmQk2any59nC4=; b=u1zj+jIRo/x/zU/jHOHYJOyqjVYT6nFPIzL9tz/+77uFBO1GVVBPe7Ff501+KS0bduJsuu +IKD/KLlN27ry/CA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702470715; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=9n4M7ojf975L20RESRcujrAHYf0j3fGmQk2any59nC4=; b=m7vg46Gpj3t9z4z1ZFRDMK/A8ADUuwRzTxnhA0PKupUn0oHpmyYulgf+VeNFLQtFk9AWz0 dFA+oW8FQorrbD2Du75CQGRyrqpK0SwRCrReeSxcP1esE/nDQU0mVtA7d91447wWVnL14l B7wFcifALnFypUHRZB2WsUrroLtpfmU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702470715; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=9n4M7ojf975L20RESRcujrAHYf0j3fGmQk2any59nC4=; b=u1zj+jIRo/x/zU/jHOHYJOyqjVYT6nFPIzL9tz/+77uFBO1GVVBPe7Ff501+KS0bduJsuu +IKD/KLlN27ry/CA== Date: Wed, 13 Dec 2023 13:30:52 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/6] Reduce the number of get_vectype_for_scalar_type calls MIME-Version: 1.0 X-Spam-Score: -0.60 Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 2.31 X-Spamd-Result: default: False [2.31 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(2.91)[0.972]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Flag: NO X-Spam-Status: No, score=-10.9 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, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Message-Id: <20231213123215.E8BD9385E02B@sourceware.org> The following removes get_vectype_for_scalar_type calls when we already have the vector type computed. It also avoids some premature and possibly redundant or unnecessary check during data-ref analysis for gathers. * tree-vect-data-refs.cc (vect_analyze_data_refs): Do not check for a vector type for gather/scatter offset. vect_check_gather_scatter does that already. * tree-vect-loop.cc (get_initial_def_for_reduction): Use the computed vector type. * tree-vect-stmts.cc (vectorizable_operation): Use the known vector type for constants/externs. --- gcc/tree-vect-data-refs.cc | 4 +--- gcc/tree-vect-loop.cc | 2 +- gcc/tree-vect-stmts.cc | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc index d5c9c4a11c2..107dffe0a64 100644 --- a/gcc/tree-vect-data-refs.cc +++ b/gcc/tree-vect-data-refs.cc @@ -4721,9 +4721,7 @@ vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf, bool *fatal) gather_scatter_info gs_info; if (!vect_check_gather_scatter (stmt_info, as_a (vinfo), - &gs_info) - || !get_vectype_for_scalar_type (vinfo, - TREE_TYPE (gs_info.offset))) + &gs_info)) { if (fatal) *fatal = false; diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 6261cd1be1d..3a0731f3bea 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -5466,7 +5466,7 @@ get_initial_def_for_reduction (loop_vec_info loop_vinfo, { class loop *loop = LOOP_VINFO_LOOP (loop_vinfo); tree scalar_type = TREE_TYPE (init_val); - tree vectype = get_vectype_for_scalar_type (loop_vinfo, scalar_type); + tree vectype = STMT_VINFO_VECTYPE (reduc_info); tree init_def; gimple_seq stmts = NULL; diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 390c8472fd6..5ad306e2b08 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -6914,7 +6914,8 @@ vectorizable_operation (vec_info *vinfo, S2: z = x + 1 - VS2_0 */ vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, - op0, &vec_oprnds0, op1, &vec_oprnds1, op2, &vec_oprnds2); + op0, vectype, &vec_oprnds0, op1, vectype, &vec_oprnds1, + op2, vectype, &vec_oprnds2); /* Arguments are ready. Create the new vector stmt. */ FOR_EACH_VEC_ELT (vec_oprnds0, i, vop0) {