From patchwork Mon Sep 23 13:26:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1988599 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=gVyPYFKK; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3CX42DL6; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=gVyPYFKK; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3CX42DL6; 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 4XC3jw0B1kz1xsg for ; Mon, 23 Sep 2024 23:29:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C9C79385840A for ; Mon, 23 Sep 2024 13:29:05 +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 CCC373858406 for ; Mon, 23 Sep 2024 13:26:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CCC373858406 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 CCC373858406 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=1727097969; cv=none; b=TpVfHaEYqHc2cT/IKhrl32I8S6evfaS+UDkXYBQtJ6Dku6d7a0k9tp54+epPT6yDFH6gZ+N+z9RtzD+U2ki4HwqX9lbsNRWoDslm+xwB1gpPGJkdCHPdXe3+jQZ9c2lDPcvavPHFxdL9P0cimOeZFDUm96uFREq0fg30GQOa9Xk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727097969; c=relaxed/simple; bh=2XfPB7WlJSddHQG2DtwqUHisSuOrWPD6JOd0NQcdk+U=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=WaQ4JZBj9cnduVXo+opSy4rI5+GcajkvxH1DdlTpUIxt32yVwPccm8/KgKmGIP0MlUZMKnxJRuOL2vUT/WRBEvb1MGCTu+SelUMwkW5ydN+AlrfVwn1JP7t3db4FC9NSuDX8RQdu53yjzbdcVY5Luxrbgfet0mC+zFeSe4qyQeQ= 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-out1.suse.de (Postfix) with ESMTPS id CB57121E28; Mon, 23 Sep 2024 13:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1727097966; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=ZLeX4D1DDptgVA/m4gOpCMi7eoUwRdJwAjSNcsvVf1c=; b=gVyPYFKK1R1tPdnbvYmReuMfDdXfTQ8Q8G8K/MVPEOKBn4grI2NRWX6miUt9LCxDuome4c yhDRKwVOoQevUT0I/gpaKvUR3YF/v1Km/6i4HKi8E/km7eYm/F3yF/SiKc34LMraydU5J9 ALfJhrAMcJDUrBMrH17xE8PaQwh9CDA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1727097966; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=ZLeX4D1DDptgVA/m4gOpCMi7eoUwRdJwAjSNcsvVf1c=; b=3CX42DL6tG7ZbPzK7un3GkryiU+LgUrnVdzmHTEBP9Nj/2XOfrcNSFeIr5E98Gv+jXHuYG GTS5TBduWO9By9Cg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1727097966; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=ZLeX4D1DDptgVA/m4gOpCMi7eoUwRdJwAjSNcsvVf1c=; b=gVyPYFKK1R1tPdnbvYmReuMfDdXfTQ8Q8G8K/MVPEOKBn4grI2NRWX6miUt9LCxDuome4c yhDRKwVOoQevUT0I/gpaKvUR3YF/v1Km/6i4HKi8E/km7eYm/F3yF/SiKc34LMraydU5J9 ALfJhrAMcJDUrBMrH17xE8PaQwh9CDA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1727097966; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=ZLeX4D1DDptgVA/m4gOpCMi7eoUwRdJwAjSNcsvVf1c=; b=3CX42DL6tG7ZbPzK7un3GkryiU+LgUrnVdzmHTEBP9Nj/2XOfrcNSFeIr5E98Gv+jXHuYG GTS5TBduWO9By9Cg== Date: Mon, 23 Sep 2024 15:26:06 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: RISC-V CI Subject: [PATCH] tree-optimization/116818 - try VMAT_GATHER_SCATTER also for SLP MIME-Version: 1.0 X-Spam-Score: -1.53 X-Spamd-Result: default: False [-1.53 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.73)[-0.733]; NEURAL_HAM_SHORT(-0.20)[-0.985]; MIME_GOOD(-0.10)[text/plain]; MISSING_XM_UA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[] X-Spam-Level: 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: <20240923132905.C9C79385840A@sourceware.org> When not doing SLP and we end up with VMAT_ELEMENTWISE we consider using strided loads, aka VMAT_GATHER_SCATTER. The following moves this logic down to also apply to SLP where we now can end up using VMAT_ELEMENTWISE as well. Bootstrap and regtest running on x86_64-unknown-linux-gnu. PR tree-optimization/116818 * tree-vect-stmts.cc (get_group_load_store_type): Consider VMAT_GATHER_SCATTER instead of VMAT_ELEMENTWISE also for SLP. --- gcc/tree-vect-stmts.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index ad08fbe5511..d74497822c4 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -2264,21 +2264,21 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, } } } + } - /* As a last resort, trying using a gather load or scatter store. + /* As a last resort, trying using a gather load or scatter store. - ??? Although the code can handle all group sizes correctly, - it probably isn't a win to use separate strided accesses based - on nearby locations. Or, even if it's a win over scalar code, - it might not be a win over vectorizing at a lower VF, if that - allows us to use contiguous accesses. */ - if (*memory_access_type == VMAT_ELEMENTWISE - && single_element_p - && loop_vinfo - && vect_use_strided_gather_scatters_p (stmt_info, loop_vinfo, - masked_p, gs_info)) - *memory_access_type = VMAT_GATHER_SCATTER; - } + ??? Although the code can handle all group sizes correctly, + it probably isn't a win to use separate strided accesses based + on nearby locations. Or, even if it's a win over scalar code, + it might not be a win over vectorizing at a lower VF, if that + allows us to use contiguous accesses. */ + if (*memory_access_type == VMAT_ELEMENTWISE + && single_element_p + && loop_vinfo + && vect_use_strided_gather_scatters_p (stmt_info, loop_vinfo, + masked_p, gs_info)) + *memory_access_type = VMAT_GATHER_SCATTER; if (*memory_access_type == VMAT_GATHER_SCATTER || *memory_access_type == VMAT_ELEMENTWISE)