From patchwork Tue Mar 5 10:45:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1908119 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=K6CLTXy/; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=e/KobV7K; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=l4ol84/X; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=dTHB6Z0u; 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 4TpsgM5g6Fz23cm for ; Tue, 5 Mar 2024 21:46:23 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 923473858438 for ; Tue, 5 Mar 2024 10:46:17 +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 EC9C73858C41 for ; Tue, 5 Mar 2024 10:45:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC9C73858C41 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 EC9C73858C41 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=1709635559; cv=none; b=pQsbLNOP06N83cTLkzMq/FFIfVucGctMo0rGionxC/iyDmln7qNSLt8KJWM7ZA4VjqO8Az56buzpGljbEoSKaLWMhZXIEFBa8GggxTJ/94SHUKCQfT1uEUO+hBWCZ1NZc4XPjy/j8HXVM2oREHJHyEMBR4OIoT7bdrhsUP25UCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709635559; c=relaxed/simple; bh=OA2zYZFegU8Dfh4X9nqVrE0Qn6ZhQmt3OkeIe9Ytet4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=RHF13zqHkZWQzj2+Hs/W9oB4X6bfXYpP4qft3f1ay09M0U7pTdiy1UurczSdqAZ+IbZfNPrS9wHiR/xtg7aRsV8WthHutENWG9Hn97rze6tdvXhHkN0kuNDbsbHnkQWqJMJNAEvD4+XEvDrFmczqmpyLKNJFclTF9bEUu0FKkpg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 E003475A39 for ; Tue, 5 Mar 2024 10:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709635557; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=uhaWBibuOoybTTkikZTyEIzoNvXNgdh0c2eu8In2IkM=; b=K6CLTXy/nEX1Ms2FNvY4LHoWYihmpB4oAiLwlpf+KL8Yc/zo/WtBPE3GigGBoYjCZanke9 GCBn9wbEQ9FeocGLszYNlGsp1dIhB6IKGyGv72nFAIH9bB+Low1py67jLdh+135IeJfgT9 FBios5N48tF+C9M+DqsHJUYuMhMDV8A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709635557; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=uhaWBibuOoybTTkikZTyEIzoNvXNgdh0c2eu8In2IkM=; b=e/KobV7KG1Vmu2wFN39AOb6xmYf3+RLPjbv/TXC0Sln1FfPYeaLJyhWVXJ1rawA5R4z71U mUvo1kFsAi7L9HAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709635556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=uhaWBibuOoybTTkikZTyEIzoNvXNgdh0c2eu8In2IkM=; b=l4ol84/XOKf/VNbzVrMRmGAC+q9At1d6UKaffc5QC87ZUVkUonfG/kSY9WrvkF4w2/bYdK MqB9rU6nccOTsJ9hGiJ99Ub/7iyfQPH/w7zziJrUU6p28JFY+6Gtg6yFOrBDhnxdS+GmqJ 1deFGNG5tPOM3/VR468Xiuo7OPV1MC8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709635556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=uhaWBibuOoybTTkikZTyEIzoNvXNgdh0c2eu8In2IkM=; b=dTHB6Z0uGTYnsZB8xVDopJwIqdnJsTJQ30AGwOW3ODcMGwXMpq97zXvjrKjRAjPJJQ6icK 6ih1lqDf1OCR3PCA== Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id C645513466 for ; Tue, 5 Mar 2024 10:45:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id dBG+LuT35mU8AgAAn2gu4w (envelope-from ) for ; Tue, 05 Mar 2024 10:45:56 +0000 Date: Tue, 5 Mar 2024 11:45:56 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/114231 - use patterns for BB SLP discovery root stmts MIME-Version: 1.0 Message-Id: <20240305104556.C645513466@imap2.dmz-prg2.suse.org> Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="l4ol84/X"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=dTHB6Z0u X-Spamd-Result: default: False [-5.31 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: E003475A39 X-Spam-Level: X-Spam-Score: -5.31 X-Spam-Status: No, score=-11.4 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 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 makes sure to use recognized patterns when vectorizing roots during BB SLP discovery. We need to apply those late since during root discovery we've not yet done pattern recognition. All parts of the vectorizer assume patterns get used, for the testcase we mix this up when doing live lane computation. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/114231 * tree-vect-slp.cc (vect_analyze_slp): Lookup patterns when processing a BB SLP root. * gcc.dg/vect/pr114231.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr114231.c | 12 ++++++++++++ gcc/tree-vect-slp.cc | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/pr114231.c diff --git a/gcc/testsuite/gcc.dg/vect/pr114231.c b/gcc/testsuite/gcc.dg/vect/pr114231.c new file mode 100644 index 00000000000..5e3a8103918 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr114231.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +void f(long*); +int ff[2]; +void f2(long, long, unsigned long); +void k(unsigned long x, unsigned long y) +{ + long t = x >> ff[0]; + long t1 = ff[1]; + unsigned long t2 = y >> ff[0]; + f2(t1, t+t2, t2); +} diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index e8844044e88..734ec4f4284 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -3634,6 +3634,10 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) for (unsigned i = 0; i < bb_vinfo->roots.length (); ++i) { vect_location = bb_vinfo->roots[i].roots[0]->stmt; + /* Apply patterns. */ + for (unsigned j = 0; j < bb_vinfo->roots[i].stmts.length (); ++j) + bb_vinfo->roots[i].stmts[j] + = vect_stmt_to_vectorize (bb_vinfo->roots[i].stmts[j]); if (vect_build_slp_instance (bb_vinfo, bb_vinfo->roots[i].kind, bb_vinfo->roots[i].stmts, bb_vinfo->roots[i].roots,