From patchwork Mon Nov 11 09:32:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 2009748 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=ja9rwgS6; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=2kqLauaL; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ja9rwgS6; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=2kqLauaL; 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 4Xn48H2Hrvz1xty for ; Mon, 11 Nov 2024 20:32:31 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 666323858C2B for ; Mon, 11 Nov 2024 09:32:29 +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 C65F03858C62 for ; Mon, 11 Nov 2024 09:32:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C65F03858C62 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 C65F03858C62 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=1731317527; cv=none; b=hF+wC1Y3yUvawbG5L8bPzDfsPcQcZC7mmM1yqA5Sx72ABpBok+41iJgln5xeYrpi/idiZuVChPF6a4BvfvceH/adp9KB171d9FvAo7SanYbX+uEoTc680u5VH82vFDN8lGHQKns+7VJ+aKNM9Lc4izrzuxN6wKEiP3cRzFpHmPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731317527; c=relaxed/simple; bh=We4jsxM2Tx+gJ3wTDUfDxHRGMhzYM5kUXp1TttmH6P0=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=hCXUaay1b9b71mEMCc77Aj2KRKRrLsNY0D9xUfF7yfwMB7qCj2mxau20MIo7GA0nFBdKmOgXjBZfkhKzrtkgWktb2QhwTt6N9f5tA6BqtIAXsBMz4MdsYn0GeLASFlA4DOccH6vCUqT/sGf9SU0GavhCkdxKhUjHod7xzGLia3s= 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 B79A8219B1; Mon, 11 Nov 2024 09:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1731317522; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=m1o+ie+cUF4R6hm72zsLe3dVnqIi5VcfjrZhVeBRyFc=; b=ja9rwgS6PZtyuY9Xzet4BjvHQYdnt/bcl5M1xvj6dHkBgPXK8boz6C3om07OA4E8IiyiNg gacsnr5riom3RHSzQaXfitqGPKK33+mQaOffPuv7KEq4bJyfms7uTEh18GY1vvVTRaYxd7 Ppkk03GzWxRX72VdrKXzzsKqy9XCbcE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1731317522; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=m1o+ie+cUF4R6hm72zsLe3dVnqIi5VcfjrZhVeBRyFc=; b=2kqLauaLzl7x5i6hwMdrQvpmv1/WHXzCxwXRXZqPZ/jy2yJ8Kk2pIwUa5r3k7U62MV9TF9 hHr2kS2UkZZnPQAA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1731317522; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=m1o+ie+cUF4R6hm72zsLe3dVnqIi5VcfjrZhVeBRyFc=; b=ja9rwgS6PZtyuY9Xzet4BjvHQYdnt/bcl5M1xvj6dHkBgPXK8boz6C3om07OA4E8IiyiNg gacsnr5riom3RHSzQaXfitqGPKK33+mQaOffPuv7KEq4bJyfms7uTEh18GY1vvVTRaYxd7 Ppkk03GzWxRX72VdrKXzzsKqy9XCbcE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1731317522; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=m1o+ie+cUF4R6hm72zsLe3dVnqIi5VcfjrZhVeBRyFc=; b=2kqLauaLzl7x5i6hwMdrQvpmv1/WHXzCxwXRXZqPZ/jy2yJ8Kk2pIwUa5r3k7U62MV9TF9 hHr2kS2UkZZnPQAA== Date: Mon, 11 Nov 2024 10:32:02 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: RISC-V CI Subject: [PATCH][v3] Add missing SLP discovery for CFN[_MASK][_LEN]_SCATTER_STORE MIME-Version: 1.0 X-Spamd-Result: default: False [-0.94 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.22)[-0.222]; NEURAL_HAM_SHORT(-0.11)[-0.566]; 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-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: <20241111093229.666323858C2B@sourceware.org> This was responsible for a bunch of SVE FAILs with --param vect-force-slp=1 Bootstrapped and tested on x86_64-unknown-linux-gnu. * tree-vect-slp.cc (arg1_arg3_map): New. (arg1_arg3_arg4_map): Likewise. (vect_get_operand_map): Handle IFN_SCATTER_STORE, IFN_MASK_SCATTER_STORE and IFN_MASK_LEN_SCATTER_STORE. (vect_build_slp_tree_1): Likewise. * tree-vect-stmts.cc (vectorizable_store): For SLP masked gather/scatter record the mask with proper number of copies. * tree-vect-loop.cc (vectorizable_recurr): Avoid costing the initial value construction in the prologue twice with SLP. --- gcc/tree-vect-loop.cc | 9 ++++++--- gcc/tree-vect-slp.cc | 17 ++++++++++++++++- gcc/tree-vect-stmts.cc | 6 ++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 3f2095da449..6cfce5aa7e1 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -9623,9 +9623,12 @@ vectorizable_recurr (loop_vec_info loop_vinfo, stmt_vec_info stmt_info, return false; /* The recurrence costs the initialization vector and one permute - for each copy. */ - unsigned prologue_cost = record_stmt_cost (cost_vec, 1, scalar_to_vec, - stmt_info, 0, vect_prologue); + for each copy. With SLP the prologue value is explicitly + represented and costed separately. */ + unsigned prologue_cost = 0; + if (!slp_node) + prologue_cost = record_stmt_cost (cost_vec, 1, scalar_to_vec, + stmt_info, 0, vect_prologue); unsigned inside_cost = record_stmt_cost (cost_vec, ncopies, vector_stmt, stmt_info, 0, vect_body); if (dump_enabled_p ()) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index d78ce036345..7ec2f278067 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -512,7 +512,9 @@ static const int no_arg_map[] = { 0 }; static const int arg0_map[] = { 1, 0 }; static const int arg1_map[] = { 1, 1 }; static const int arg2_map[] = { 1, 2 }; +static const int arg1_arg3_map[] = { 2, 1, 3 }; static const int arg1_arg4_map[] = { 2, 1, 4 }; +static const int arg1_arg3_arg4_map[] = { 3, 1, 3, 4 }; static const int arg3_arg2_map[] = { 2, 3, 2 }; static const int op1_op0_map[] = { 2, 1, 0 }; static const int off_map[] = { 1, -3 }; @@ -573,6 +575,13 @@ vect_get_operand_map (const gimple *stmt, bool gather_scatter_p = false, case IFN_MASK_LEN_GATHER_LOAD: return arg1_arg4_map; + case IFN_SCATTER_STORE: + return arg1_arg3_map; + + case IFN_MASK_SCATTER_STORE: + case IFN_MASK_LEN_SCATTER_STORE: + return arg1_arg3_arg4_map; + case IFN_MASK_STORE: return gather_scatter_p ? off_arg3_arg2_map : arg3_arg2_map; @@ -1187,7 +1196,10 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, if (cfn == CFN_MASK_LOAD || cfn == CFN_GATHER_LOAD || cfn == CFN_MASK_GATHER_LOAD - || cfn == CFN_MASK_LEN_GATHER_LOAD) + || cfn == CFN_MASK_LEN_GATHER_LOAD + || cfn == CFN_SCATTER_STORE + || cfn == CFN_MASK_SCATTER_STORE + || cfn == CFN_MASK_LEN_SCATTER_STORE) ldst_p = true; else if (cfn == CFN_MASK_STORE) { @@ -1473,6 +1485,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, && rhs_code != CFN_GATHER_LOAD && rhs_code != CFN_MASK_GATHER_LOAD && rhs_code != CFN_MASK_LEN_GATHER_LOAD + && rhs_code != CFN_SCATTER_STORE + && rhs_code != CFN_MASK_SCATTER_STORE + && rhs_code != CFN_MASK_LEN_SCATTER_STORE && !STMT_VINFO_GATHER_SCATTER_P (stmt_info) /* Not grouped loads are handled as externals for BB vectorization. For loop vectorization we can handle diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index b281beb8d65..fa44e19f163 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -9162,7 +9162,8 @@ vectorizable_store (vec_info *vinfo, { if (loop_masks) final_mask = vect_get_loop_mask (loop_vinfo, gsi, - loop_masks, ncopies, + loop_masks, + ncopies * vec_num, vectype, j); if (vec_mask) final_mask = prepare_vec_mask (loop_vinfo, mask_vectype, @@ -9188,7 +9189,8 @@ vectorizable_store (vec_info *vinfo, { if (loop_lens) final_len = vect_get_loop_len (loop_vinfo, gsi, - loop_lens, ncopies, + loop_lens, + ncopies * vec_num, vectype, j, 1); else final_len = size_int (TYPE_VECTOR_SUBPARTS (vectype));