From patchwork Thu Jul 25 13:14:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1964749 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=F6ta9mo4; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FF3JFV0/; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=F6ta9mo4; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FF3JFV0/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WVBDx4sgHz1yY9 for ; Thu, 25 Jul 2024 23:14:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BF5B13858430 for ; Thu, 25 Jul 2024 13:14:39 +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 7AFB63858D35 for ; Thu, 25 Jul 2024 13:14:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AFB63858D35 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 7AFB63858D35 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=1721913261; cv=none; b=Xa4sQ6htc3fngRjkJAdqUrEEaOZ76Qunrlmhy3dTnvVLt7LBuFKqxzvtR05F+sQNxHdfR/j/Dv1QYWZPAbmHSSeUIzISN9DIxsPiSn26znAZHd21KKIrJ896YDcARuEDwJDEd0ghe+2Ebq7pr3NknizdQTRHKYYld5qxy7a+FXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721913261; c=relaxed/simple; bh=Aw72KBvhBvgsCnC2xNN3KdKOIGaZhKfeG+SKNKojAQA=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=mdCmen9DI/6Jh7PfOTSRSWTtRkjJjjXXIdzXyiZbf2RxFdPp/5LMUL8fWwJTCVcYOq3QmUP/MszZzr+Yj0nIYYbAB2Bynn9fcekFeeZ0njn6vGit5AYdQ+PSwcvU7xNYJ53QPe+ZU3DSIUZPgMIZ0O0rj48f5NZ9ulAro9/DCEE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 5E9B61F80A for ; Thu, 25 Jul 2024 13:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721913257; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=uoYyC6fiTLzxo4B9/wtxf1dv9rBtbPRnvWmkKwmRs1A=; b=F6ta9mo4L3bRjvGYeKUN5eFZEvH6KI4EAvTSdhSjC4qXyVowe9dOxp63UTg33Z7M1MSaih +ZW+QD0T8Gw4ogtJV8mZKTsOxJZ+HnAXMc6jSKezF5n0E6H3BPIa7BrTt/PUXU5vt/oM6g Jt3mqtLr1ggy/kWWl6JlSb+c76e+dMI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721913257; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=uoYyC6fiTLzxo4B9/wtxf1dv9rBtbPRnvWmkKwmRs1A=; b=FF3JFV0/BVoW5cT4ZYnF6CXORi9mUdVMN3XcxJc4cvhxr1WKYUknpttT50NG26DHj7tVPh Km3VxiajuPKfMkCw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=F6ta9mo4; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="FF3JFV0/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721913257; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=uoYyC6fiTLzxo4B9/wtxf1dv9rBtbPRnvWmkKwmRs1A=; b=F6ta9mo4L3bRjvGYeKUN5eFZEvH6KI4EAvTSdhSjC4qXyVowe9dOxp63UTg33Z7M1MSaih +ZW+QD0T8Gw4ogtJV8mZKTsOxJZ+HnAXMc6jSKezF5n0E6H3BPIa7BrTt/PUXU5vt/oM6g Jt3mqtLr1ggy/kWWl6JlSb+c76e+dMI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721913257; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=uoYyC6fiTLzxo4B9/wtxf1dv9rBtbPRnvWmkKwmRs1A=; b=FF3JFV0/BVoW5cT4ZYnF6CXORi9mUdVMN3XcxJc4cvhxr1WKYUknpttT50NG26DHj7tVPh Km3VxiajuPKfMkCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 45D4C13874 for ; Thu, 25 Jul 2024 13:14:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eipxD6lPombSfAAAD6G6ig (envelope-from ) for ; Thu, 25 Jul 2024 13:14:17 +0000 Date: Thu, 25 Jul 2024 15:14:16 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/116083 - improve behavior when SLP discovery limit is reached MIME-Version: 1.0 Message-Id: <20240725131417.45D4C13874@imap1.dmz-prg2.suse.org> X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-1.31 / 50.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_TLS_ALL(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Score: -1.31 X-Rspamd-Queue-Id: 5E9B61F80A X-Spam-Status: No, score=-11.7 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 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 The following avoids some useless work when the SLP discovery limit is reached, for example allocating a node to cache the failure and starting discovery on split store groups when analyzing BBs. It does not address the issue in the PR which is a gratious budget for discovery when the store group size approaches the number of overall statements. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/116083 * tree-vect-slp.cc (vect_build_slp_tree): Do not allocate a discovery fail node when we reached the discovery limit. (vect_build_slp_instance): Terminate early when the discovery limit is reached. --- gcc/tree-vect-slp.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 8c7dfc4feca..7da5853adf6 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -1756,13 +1756,6 @@ vect_build_slp_tree (vec_info *vinfo, return NULL; } - /* Seed the bst_map with a stub node to be filled by vect_build_slp_tree_2 - so we can pick up backedge destinations during discovery. */ - slp_tree res = new _slp_tree; - SLP_TREE_DEF_TYPE (res) = vect_internal_def; - SLP_TREE_SCALAR_STMTS (res) = stmts; - bst_map->put (stmts.copy (), res); - /* Single-lane SLP doesn't have the chance of run-away, do not account it to the limit. */ if (stmts.length () > 1) @@ -1772,18 +1765,19 @@ vect_build_slp_tree (vec_info *vinfo, if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "SLP discovery limit exceeded\n"); - /* Mark the node invalid so we can detect those when still in use - as backedge destinations. */ - SLP_TREE_SCALAR_STMTS (res) = vNULL; - SLP_TREE_DEF_TYPE (res) = vect_uninitialized_def; - res->failed = XNEWVEC (bool, group_size); - memset (res->failed, 0, sizeof (bool) * group_size); memset (matches, 0, sizeof (bool) * group_size); return NULL; } --*limit; } + /* Seed the bst_map with a stub node to be filled by vect_build_slp_tree_2 + so we can pick up backedge destinations during discovery. */ + slp_tree res = new _slp_tree; + SLP_TREE_DEF_TYPE (res) = vect_internal_def; + SLP_TREE_SCALAR_STMTS (res) = stmts; + bst_map->put (stmts.copy (), res); + if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "starting SLP discovery for node %p\n", (void *) res); @@ -3368,6 +3362,10 @@ vect_build_slp_instance (vec_info *vinfo, /* ??? We need stmt_info for group splitting. */ stmt_vec_info stmt_info_) { + /* If there's no budget left bail out early. */ + if (*limit == 0) + return false; + if (kind == slp_inst_kind_ctor) { if (dump_enabled_p ()) @@ -3525,7 +3523,7 @@ vect_build_slp_instance (vec_info *vinfo, stmt_vec_info stmt_info = stmt_info_; /* Try to break the group up into pieces. */ - if (kind == slp_inst_kind_store) + if (*limit > 0 && kind == slp_inst_kind_store) { /* ??? We could delay all the actual splitting of store-groups until after SLP discovery of the original group completed.