From patchwork Tue Sep 17 11:09:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1986395 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=IIIZNH45; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4JBaIY58; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=IIIZNH45; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4JBaIY58; 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 4X7Jvp24z0z1y1t for ; Tue, 17 Sep 2024 21:09:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0EFCF3858C98 for ; Tue, 17 Sep 2024 11:09:40 +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 [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 611893858D26 for ; Tue, 17 Sep 2024 11:09:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 611893858D26 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 611893858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726571360; cv=none; b=anxXVUpycdnP1WWcNYTo+eWzyJO/4EED7iYyCIJOxH6wEEN/7pAkJJ6LH2ilxhwzEfoshw+QpQygrX5+q43grUqBUHfOw99DSOc6mvrNfrsyHxeR6VgKmiwosYdnymGfOZsdf9tAO5OqPrOIFI3LYefQCgBjkHFTGRmW4ZpgG8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726571360; c=relaxed/simple; bh=Tsy6XtLGeZRmE/dOalr2svXMIV0a/NLIibehsPEmDts=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=RPCeMY3qCST9qQMWL0Z1BSp16TTMzMKPprLzqa4549PzJBY1P1kHBqgjCxoc3V+/8JsGAQqSzlT3fSuOenLXiP2LajuqI72Mvbdt1dgh5hb7s6jvunGaOn2CE5ytpycf5orcDbLskhCU4muw+i73UucJyAzjmsLiMxVljF1tajc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [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-out1.suse.de (Postfix) with ESMTPS id 0224C2217D; Tue, 17 Sep 2024 11:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1726571357; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=qJtgj8N/0VYnrx3TCwrVrql4rUC1eVa/sTaFWz4/0cs=; b=IIIZNH45uE0lK3Z3KwO8fiNt4Yw0WMHxtcAFAsb6kppQotIjIAubl8FIX26/fyTjU8HlhM BNaicH2vPCkH0y5t6R7i97C5xQzDAHulYmW3At4tBwqgizYBS4x7iTJtCo9hmaWRjjPcGj JNnioF/NmryFOJ2rgpW1fGNd1w1ghh4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1726571357; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=qJtgj8N/0VYnrx3TCwrVrql4rUC1eVa/sTaFWz4/0cs=; b=4JBaIY58pw3uA8kEHrWJA90+OpWtwKyokfvvDzC+B24K4Z/LDKfdvORwlDY1+lsLHtsRng Sf8jMsQEf+9DXEAw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1726571357; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=qJtgj8N/0VYnrx3TCwrVrql4rUC1eVa/sTaFWz4/0cs=; b=IIIZNH45uE0lK3Z3KwO8fiNt4Yw0WMHxtcAFAsb6kppQotIjIAubl8FIX26/fyTjU8HlhM BNaicH2vPCkH0y5t6R7i97C5xQzDAHulYmW3At4tBwqgizYBS4x7iTJtCo9hmaWRjjPcGj JNnioF/NmryFOJ2rgpW1fGNd1w1ghh4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1726571357; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=qJtgj8N/0VYnrx3TCwrVrql4rUC1eVa/sTaFWz4/0cs=; b=4JBaIY58pw3uA8kEHrWJA90+OpWtwKyokfvvDzC+B24K4Z/LDKfdvORwlDY1+lsLHtsRng Sf8jMsQEf+9DXEAw== 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 D532E139CE; Tue, 17 Sep 2024 11:09:16 +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 2aNqMlxj6WapBAAAD6G6ig (envelope-from ); Tue, 17 Sep 2024 11:09:16 +0000 Date: Tue, 17 Sep 2024 13:09:08 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: RISC-V Subject: [PATCH][v2] tree-optimization/116573 - .SELECT_VL for SLP MIME-Version: 1.0 Message-Id: <20240917110916.D532E139CE@imap1.dmz-prg2.suse.org> X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[] X-Spam-Score: -4.30 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 restores the use of .SELECT_VL for testcases where it is safe to use even when using SLP. I've for now restricted it to single-lane SLP plus optimistically allow store-lane nodes and assume single-lane roots are not widened but at most to load-lane who should be fine. v2 fixes latent issues in vectorizable_load/store. Bootstrap and regtest running on x86_64-unknown-linux-gnu. PR tree-optimization/116573 * tree-vect-loop.cc (vect_analyze_loop_2): Allow .SELECV_VL for SLP but disable it when there's multi-lane instances. * tree-vect-stmts.cc (vectorizable_store): Only compute the ptr increment when generating code. (vectorizable_load): Likewise. --- gcc/tree-vect-loop.cc | 15 ++++++++++++++- gcc/tree-vect-stmts.cc | 10 ++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 62c7f90779f..199d79029e4 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -3078,10 +3078,23 @@ start_over: if (direct_internal_fn_supported_p (IFN_SELECT_VL, iv_type, OPTIMIZE_FOR_SPEED) && LOOP_VINFO_LENS (loop_vinfo).length () == 1 - && LOOP_VINFO_LENS (loop_vinfo)[0].factor == 1 && !slp + && LOOP_VINFO_LENS (loop_vinfo)[0].factor == 1 && (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) || !LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ())) LOOP_VINFO_USING_SELECT_VL_P (loop_vinfo) = true; + + /* If any of the SLP instances cover more than a single lane + we cannot use .SELECT_VL at the moment, even if the number + of lanes is uniform throughout the SLP graph. */ + if (LOOP_VINFO_USING_SELECT_VL_P (loop_vinfo)) + for (slp_instance inst : LOOP_VINFO_SLP_INSTANCES (loop_vinfo)) + if (SLP_TREE_LANES (SLP_INSTANCE_TREE (inst)) != 1 + && !(SLP_INSTANCE_KIND (inst) == slp_inst_kind_store + && SLP_INSTANCE_TREE (inst)->ldst_lanes)) + { + LOOP_VINFO_USING_SELECT_VL_P (loop_vinfo) = false; + break; + } } /* Decide whether this loop_vinfo should use partial vectors or peeling, diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index b1353c91fce..9b9a30600a9 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -8744,8 +8744,9 @@ vectorizable_store (vec_info *vinfo, aggr_type = build_array_type_nelts (elem_type, group_size * nunits); else aggr_type = vectype; - bump = vect_get_data_ptr_increment (vinfo, gsi, dr_info, aggr_type, - memory_access_type, loop_lens); + if (!costing_p) + bump = vect_get_data_ptr_increment (vinfo, gsi, dr_info, aggr_type, + memory_access_type, loop_lens); } if (mask && !costing_p) @@ -10820,8 +10821,9 @@ vectorizable_load (vec_info *vinfo, aggr_type = build_array_type_nelts (elem_type, group_size * nunits); else aggr_type = vectype; - bump = vect_get_data_ptr_increment (vinfo, gsi, dr_info, aggr_type, - memory_access_type, loop_lens); + if (!costing_p) + bump = vect_get_data_ptr_increment (vinfo, gsi, dr_info, aggr_type, + memory_access_type, loop_lens); } auto_vec vec_offsets;