From patchwork Mon Sep 23 09:52:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1988507 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=1vv6EWSx; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3WbiOMCg; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=1vv6EWSx; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3WbiOMCg; 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 4XByvy15PQz1xsM for ; Mon, 23 Sep 2024 19:52:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F53D3858C39 for ; Mon, 23 Sep 2024 09:52: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 [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 640863858D20 for ; Mon, 23 Sep 2024 09:52:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 640863858D20 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 640863858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727085127; cv=none; b=lzK9cqfdCnTGoHDooyzrlp64YEn8asl3valnSrjEPfRivnTepuL5UcRafdcWvqPrU+oH3oK0pSlL9TpMNg9bnTSmcvCF/BtEIy2aOHHRw+V6fIIM60L5ui37c1yUsaeByhGg8iaIPFVAfVWLqlQQVKrWmNrUP+R69rfomwAQlIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727085127; c=relaxed/simple; bh=u8hGH1k+oQyaKR6EDSKZIMa6sHfX408De8A/7qo5MAY=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=l5rtUO1/1cd7kNVDG30ervHndAJ7Fwk13lzWotYmoHdh6KDO9aE0kmt1NQT2rsRFvlQDkD+Y/4Pv5kc4gxOZnCTSIHqQway/c5EZHwBJ+qNj8uhLyiK2c0evZ8+8PjskzGRHG2Fk/1011CqcThfxnKupzvB5eZ0F2+jcRPApTIA= 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 518651FB7C for ; Mon, 23 Sep 2024 09:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1727085124; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=7UZLfaITSSP8cGye4EV6UvvRqreeOGJYPdcmvtZfO04=; b=1vv6EWSxA1gA6j03/LjVNck8nE6K0FD31I6d4gY6AesYfxmgKcw5wQMHp2cvcSF5XuPOlr EqKFtH4oeC+59FQYAfXErYEL/DDGMNpajfM2wv2FQLf6Vs1B0vRkLxrp3w8FShdryxtL70 CSqFybiRTjy9sQbyamjr/0T4L4loepE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1727085124; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=7UZLfaITSSP8cGye4EV6UvvRqreeOGJYPdcmvtZfO04=; b=3WbiOMCgqSYjfldBZ3/VDM2+DG7rhUtFbcJSJp2B/ppqfTWIuVXpZbywWD/IZwKxApGsR6 oHkDtL0GaGucuYAA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1727085124; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=7UZLfaITSSP8cGye4EV6UvvRqreeOGJYPdcmvtZfO04=; b=1vv6EWSxA1gA6j03/LjVNck8nE6K0FD31I6d4gY6AesYfxmgKcw5wQMHp2cvcSF5XuPOlr EqKFtH4oeC+59FQYAfXErYEL/DDGMNpajfM2wv2FQLf6Vs1B0vRkLxrp3w8FShdryxtL70 CSqFybiRTjy9sQbyamjr/0T4L4loepE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1727085124; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=7UZLfaITSSP8cGye4EV6UvvRqreeOGJYPdcmvtZfO04=; b=3WbiOMCgqSYjfldBZ3/VDM2+DG7rhUtFbcJSJp2B/ppqfTWIuVXpZbywWD/IZwKxApGsR6 oHkDtL0GaGucuYAA== Date: Mon, 23 Sep 2024 11:52:04 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/116791 - Elementwise SLP vectorization MIME-Version: 1.0 X-Spam-Score: -1.11 X-Spamd-Result: default: False [-1.11 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.33)[-0.328]; NEURAL_HAM_SHORT(-0.18)[-0.916]; 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-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: <20240923095228.4F53D3858C39@sourceware.org> The following restricts the elementwise SLP vectorization to the single-lane case which is the reason I enabled it to avoid regressions with non-SLP. The PR shows that multi-line SLP loads with elementwise accesses require work, I'll open a new bug to track this for the future. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. Richard. PR tree-optimization/116791 * tree-vect-stmts.cc (get_group_load_store_type): Only fall back to elementwise access for single-lane SLP, restore hard failure mode for other cases. * gcc.dg/vect/pr116791.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr116791.c | 20 ++++++++++++++++++++ gcc/tree-vect-stmts.cc | 23 +++++++++++++++++------ 2 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr116791.c diff --git a/gcc/testsuite/gcc.dg/vect/pr116791.c b/gcc/testsuite/gcc.dg/vect/pr116791.c new file mode 100644 index 00000000000..d9700a88fcc --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr116791.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +struct nine_context { + unsigned tex_stage[8][33]; +}; +struct fvec4 { + float x[2]; +}; +void f(struct fvec4 *dst, struct nine_context *context) +{ + unsigned s; + for (s = 0; s < 8; ++s) + { + float *rgba = &dst[s].x[0]; + unsigned color = context->tex_stage[s][0]; + rgba[0] = (float)((color >> 16) & 0xFF) / 0xFF; + rgba[1] = (float)((color >> 8) & 0xFF) / 0xFF; + } +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index a7032c21d66..2e85b683789 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -2192,12 +2192,23 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, && single_element_p && maybe_gt (group_size, TYPE_VECTOR_SUBPARTS (vectype))) { - *memory_access_type = VMAT_ELEMENTWISE; - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "single-element interleaving not supported " - "for not adjacent vector loads, using " - "elementwise access\n"); + if (SLP_TREE_LANES (slp_node) == 1) + { + *memory_access_type = VMAT_ELEMENTWISE; + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "single-element interleaving not supported " + "for not adjacent vector loads, using " + "elementwise access\n"); + } + else + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "single-element interleaving not supported " + "for not adjacent vector loads\n"); + return false; + } } } }