From patchwork Thu Sep 12 07:20:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1984431 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=cMFJ+nW+; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=9D0h3sZL; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=cMFJ+nW+; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=9D0h3sZL; 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 4X483f5Yyfz1y1C for ; Thu, 12 Sep 2024 17:20:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A7A19385C6CE for ; Thu, 12 Sep 2024 07:20:28 +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 [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id CA03E3858CDA for ; Thu, 12 Sep 2024 07:20:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA03E3858CDA 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 CA03E3858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726125608; cv=none; b=OpeLZOZb8wVND3eLuzNWQbb4VzkGnShUr8OlwMBM45C3Zy7oIPcraP/BecV2d+6HPiH1S3VcQCCQnjaKarWVw5GzOEYtzRo1nI8T7lRdvvfKCFrInNIS2f+QT/RSbnRoU0D6TOWN+7kxQ24jUZv5L+4uwy8Sp9X/z2rDrpaGb3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726125608; c=relaxed/simple; bh=Zz/FP2WdBcVzXaGm0dlT7x/tRxruLxctM3plvh+hmfs=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=xK1TanvsF4um7mzBgJCWaY/ghSvfOwUBoEXw709m20a4+yq2pc6C7z5jxubJLgDJcsn8xW5ppvOlNQoCEq6sMYldnAucd3hGH/H9jjJ8QAlHSfkDgr6MKhStxpTVo9USzX/j3dlIbiQ/uQdjm2WpSuzODSuRMmywIVwllBL1HfM= 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 AB5091FB62 for ; Thu, 12 Sep 2024 07:20:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1726125605; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=UwRvw7R70KoDZgbEDp+XQqoUmyJR36GvqAdv6Mu3CPw=; b=cMFJ+nW+J0PnJeOZa+roN/L3gc792je06o42jkBLejTBjbM4JHZkv56XTT0cbSfSJ0zJG3 XR5sH68L8henZhxmJHpEwmFFaAeijbc5f0Aato7MQf+L5zsYcIfZTWoLKZ01zI54UO1Sid RpfnDywdp33Xa0pSXH5680NJTr/GKXs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1726125605; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=UwRvw7R70KoDZgbEDp+XQqoUmyJR36GvqAdv6Mu3CPw=; b=9D0h3sZLgomPDVvhXkm1FR7TLVNjqEVVWYqaWKyWtlEhG3PGHTtebudMnAForC9iujFPUr BB2SR9NbCswLoCCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1726125605; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=UwRvw7R70KoDZgbEDp+XQqoUmyJR36GvqAdv6Mu3CPw=; b=cMFJ+nW+J0PnJeOZa+roN/L3gc792je06o42jkBLejTBjbM4JHZkv56XTT0cbSfSJ0zJG3 XR5sH68L8henZhxmJHpEwmFFaAeijbc5f0Aato7MQf+L5zsYcIfZTWoLKZ01zI54UO1Sid RpfnDywdp33Xa0pSXH5680NJTr/GKXs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1726125605; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=UwRvw7R70KoDZgbEDp+XQqoUmyJR36GvqAdv6Mu3CPw=; b=9D0h3sZLgomPDVvhXkm1FR7TLVNjqEVVWYqaWKyWtlEhG3PGHTtebudMnAForC9iujFPUr BB2SR9NbCswLoCCA== Date: Thu, 12 Sep 2024 09:20:05 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Better recover from SLP reassociation fails during discovery MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-1.11 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.31)[-0.307]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; 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-Score: -1.11 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 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: <20240912072028.A7A19385C6CE@sourceware.org> When we decide to not process a association chain of size two and that would also mismatch with a different chain size on another lane we shouldn't fail discovery hard at this point. Instead let the regular discovery figure out matching lanes so the parent can decide to perform operand swapping or we can split groups at better points rather than forcefully splitting away the first single lane. For example on gcc.dg/vect/vect-strided-u8-i8.c we now see two groups of size 4 feeding the store instead of groups of size 1, three, two, one and one. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. Richard. * tree-vect-slp.cc (vect_build_slp_tree_2): On reassociation chain length mismatch do not fail discovery of the node but try without re-associating to compute a better matches[]. Provide a reassociation failure hint in the dump. (vect_slp_analyze_node_operations): Avoid stray failure dumping. (vectorizable_slp_permutation_1): Dump the address of the SLP node representing the permutation. --- gcc/tree-vect-slp.cc | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 0fb17340bd3..2c296bc1926 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -2143,19 +2143,11 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node, if (chain.length () == 2) { /* In a chain of just two elements resort to the regular - operand swapping scheme. If we run into a length - mismatch still hard-FAIL. */ - if (chain_len == 0) - hard_fail = false; - else - { - matches[lane] = false; - /* ??? We might want to process the other lanes, but - make sure to not give false matching hints to the - caller for lanes we did not process. */ - if (lane != group_size - 1) - matches[0] = false; - } + operand swapping scheme. Likewise if we run into a + length mismatch process regularly as well as we did not + process the other lanes we cannot report a good hint what + lanes to try swapping in the parent. */ + hard_fail = false; break; } else if (chain_len == 0) @@ -2428,6 +2420,11 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node, return node; } out: + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "failed to line up SLP graph by re-associating " + "operations in lanes%s\n", + !hard_fail ? " trying regular discovery" : ""); while (!children.is_empty ()) vect_free_slp_tree (children.pop ()); while (!chains.is_empty ()) @@ -7553,7 +7550,9 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node, /* We're having difficulties scheduling nodes with just constant operands and no scalar stmts since we then cannot compute a stmt insertion place. */ - if (!seen_non_constant_child && SLP_TREE_SCALAR_STMTS (node).is_empty ()) + if (res + && !seen_non_constant_child + && SLP_TREE_SCALAR_STMTS (node).is_empty ()) { if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, @@ -10279,7 +10278,7 @@ vectorizable_slp_permutation_1 (vec_info *vinfo, gimple_stmt_iterator *gsi, if (dump_p) { dump_printf_loc (MSG_NOTE, vect_location, - "vectorizing permutation"); + "vectorizing permutation %p", (void *)node); for (unsigned i = 0; i < perm.length (); ++i) dump_printf (MSG_NOTE, " op%u[%u]", perm[i].first, perm[i].second); if (repeating_p)