From patchwork Wed Sep 4 11:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1980681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=T+7qGfnD; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1hPKrKpZ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=T+7qGfnD; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1hPKrKpZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzKYf1QbZz1yg3 for ; Wed, 4 Sep 2024 21:11:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41FD93858424 for ; Wed, 4 Sep 2024 11:11:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id B43083858C98 for ; Wed, 4 Sep 2024 11:10:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B43083858C98 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 B43083858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725448257; cv=none; b=FbV7wTHTM9MSCw0DBbYiVI+AYk5UvF30uovDpOwfOEe/42ulxl2jTBA5xrtojOqa9C81ADZUIYB5I0s13Pm9f4gqaz/ywu1gH+sdOxo4FMPkPCOWmuM7ycJrM6cp4L+R945IBMkmZJBHhH8+YR1JKmeRMTnoipQLWa0vm3N0Tww= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725448257; c=relaxed/simple; bh=xTMA5BBst7pQhEVAKtSZN3mi6TnaIRPUBLM5DoHjW/w=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=YRW9C0yagRUx/KIFJVNri+zR5upfagrnjqGal1NaCv063sMxQ61iaVwUZk3Kppt31UD73cBUtXDp5JSENcDv8DthdZ3miqTPqkVGfUViuiXN3ziaH8hobbliE/GKBsLuyn3ojx/ccvQ/WPYwmSdGRunLZ2t0Sq2puYrcWDEa+2I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (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-out2.suse.de (Postfix) with ESMTPS id 8B3101F7B9 for ; Wed, 4 Sep 2024 11:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1725448252; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=fwzegcoHkT4H9+bh6zzUQl45czYJsrftfXiJXr5/+sY=; b=T+7qGfnDmcR8miFzTaKS3rYlHuvrHPDhja5eimQ62fbr8CzaUZF50cGdyLynnCdmNPG8io rqIz9/wxHYmBUXTNFoJDTc8xct2tSkuIVJt8qcs71JwDzujEKu4M/8dT5n7xmQKp2+4ipW ndCh7JsX5OsdXK+cIB5ovPJpPwsjbnI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1725448252; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=fwzegcoHkT4H9+bh6zzUQl45czYJsrftfXiJXr5/+sY=; b=1hPKrKpZwe1kNGG9FZec1ZNNQ7v/T8WafdwclgH++W2b+cCjqGDH4kWoMVRABER+QcdOU+ 8QjF26HchSISE5Ag== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1725448252; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=fwzegcoHkT4H9+bh6zzUQl45czYJsrftfXiJXr5/+sY=; b=T+7qGfnDmcR8miFzTaKS3rYlHuvrHPDhja5eimQ62fbr8CzaUZF50cGdyLynnCdmNPG8io rqIz9/wxHYmBUXTNFoJDTc8xct2tSkuIVJt8qcs71JwDzujEKu4M/8dT5n7xmQKp2+4ipW ndCh7JsX5OsdXK+cIB5ovPJpPwsjbnI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1725448252; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=fwzegcoHkT4H9+bh6zzUQl45czYJsrftfXiJXr5/+sY=; b=1hPKrKpZwe1kNGG9FZec1ZNNQ7v/T8WafdwclgH++W2b+cCjqGDH4kWoMVRABER+QcdOU+ 8QjF26HchSISE5Ag== Date: Wed, 4 Sep 2024 13:10:52 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] RISC-V: Handle unused-only-live stmts in SLP discovery MIME-Version: 1.0 X-Spam-Score: -0.92 X-Spamd-Result: default: False [-0.92 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.31)[-0.314]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_SHORT(-0.00)[-0.018]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[] X-Spam-Level: X-Spam-Status: No, score=-10.5 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~incoming=patchwork.ozlabs.org@gcc.gnu.org Message-Id: <20240904111114.41FD93858424@sourceware.org> The following adds SLP discovery for roots that are only live but otherwise unused. These are usually inductions. This allows a few more testcases to be handled fully with SLP, for example gcc.dg/vect/no-scevccp-pr86725-1.c Bootstrap and regtest running on x86_64-unknown-linux-gnu. * tree-vect-slp.cc (vect_analyze_slp): Analyze SLP for live but otherwise unused defs. --- gcc/tree-vect-slp.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 41bc92b138a..91d6927016d 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -4704,6 +4704,36 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) saved_stmts.release (); } } + + /* Make sure to vectorize only-live stmts, usually inductions. */ + for (edge e : get_loop_exit_edges (LOOP_VINFO_LOOP (loop_vinfo))) + for (auto gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); + gsi_next (&gsi)) + { + gphi *lc_phi = *gsi; + tree def = gimple_phi_arg_def_from_edge (lc_phi, e); + stmt_vec_info stmt_info; + if (TREE_CODE (def) == SSA_NAME + && !virtual_operand_p (def) + && (stmt_info = loop_vinfo->lookup_def (def)) + && STMT_VINFO_RELEVANT (stmt_info) == vect_used_only_live + && STMT_VINFO_LIVE_P (stmt_info) + && (STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def + || (STMT_VINFO_DEF_TYPE (stmt_info) == vect_internal_def + && STMT_VINFO_REDUC_IDX (stmt_info) == -1))) + { + vec stmts; + vec roots = vNULL; + vec remain = vNULL; + stmts.create (1); + stmts.quick_push (vect_stmt_to_vectorize (stmt_info)); + vect_build_slp_instance (vinfo, + slp_inst_kind_reduc_group, + stmts, roots, remain, + max_tree_size, &limit, + bst_map, NULL); + } + } } hash_set visited_patterns;