From patchwork Mon Oct 28 10:28:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 2003211 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=cVnwYggS; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=gCj/BY85; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ZbKkTQH/; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=a6Md1Ww2; 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 4XcV3x3RrHz1xwF for ; Mon, 28 Oct 2024 21:29:01 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D5F83858C32 for ; Mon, 28 Oct 2024 10:28:59 +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 [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 019263858D20 for ; Mon, 28 Oct 2024 10:28:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 019263858D20 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 019263858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730111320; cv=none; b=NrQ9GrcJjkx75ClBKGH8/EqWSiFsT18DXwyFMKIWQ/5iVrHmEgR535/UAD9ELBE5VRmcfJ4fLJZYCU4I7VGtYZeygl/8i+iC+aoN1o/k0H1JbrNbMAdRTM09nh5eUtl7ivI30goNfxwt3wOkqWg6VhCCs0PZRvyy9Fy2/KwyIQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730111320; c=relaxed/simple; bh=JDkpXtXmpmUTe+bHG7lJ5MXlNEDJy5k2aPVIYUvOndQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=P2EZNj3ATA1D8HoFoV4NMIRcxOuajMTNxLLKqoJtb45cpNIzj0EjsXnhaU34uDnAIyO1/VePL5HpwLuQKaNeEys9dn9HsrSlSKCXQ+Kef7dFr1RkFuHYOPvdsP0vsGXD/xZKOxdHVM+6gCmzndwW8Od2B4t6UdTXkyyP8dIYHkQ= 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 EAD9521C6D for ; Mon, 28 Oct 2024 10:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730111317; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=k3qXrNi62BUG91J0TPZQs6y3IOKHWxUJ+lH+kKb64yI=; b=cVnwYggSLyXRHs6sq4EIj/IjyIdJSsL2fMtp4hDPUIDm/4Z0SAfY59cLxahMzq8+7OP5F+ 5EtzI5ju8rc1/fEXkZHiMrTVA4x9g58GUuN/9vbsOL0rxV4rsApGsi/29cW3aTirljpp07 oOAULEoV+U8HYN+vNRkblryyF4EDQyw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730111317; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=k3qXrNi62BUG91J0TPZQs6y3IOKHWxUJ+lH+kKb64yI=; b=gCj/BY85nfayyTNGcbWeHFqyNPg/l0NNVpPADFcnf8C/CTuO7H4CNGftXQM95MW4foTilS E/hhSrOrkDbmJiDQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730111316; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=k3qXrNi62BUG91J0TPZQs6y3IOKHWxUJ+lH+kKb64yI=; b=ZbKkTQH/QyuNq93Q4eKawX9uExEFZuprHiBMihBgCwO2u3E+FCsQ1HwyO/7G7P+xyTR7fc LlnsO45+TSpFpWlhkVowEkO+PFWDt6/xno8GkmeP3UjpN+LYl2Y51+vOitymwr1cdvMQwM gfanhAHBVmF/voHpMDcs6ugOxpirM1U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730111316; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=k3qXrNi62BUG91J0TPZQs6y3IOKHWxUJ+lH+kKb64yI=; b=a6Md1Ww2gfSCcX8rqWtKasnnyUNbSEPoIvVgJjsAxjX/0ZYmkvU8g4F4BqBd3V4NupLam3 PVOZXqkbPFVBfgBw== 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 D16E8137D4 for ; Mon, 28 Oct 2024 10:28:36 +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 ycV8MVRnH2frOAAAD6G6ig (envelope-from ) for ; Mon, 28 Oct 2024 10:28:36 +0000 Date: Mon, 28 Oct 2024 11:28:32 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/117307 - STMT_VINFO_SLP_VECT_ONLY mis-computation MIME-Version: 1.0 Message-Id: <20241028102836.D16E8137D4@imap1.dmz-prg2.suse.org> X-Spam-Score: -4.30 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_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Status: No, score=-11.8 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 STMT_VINFO_SLP_VECT_ONLY isn't properly computed as union of all group members and when the group is later split due to duplicates not all sub-groups inherit the flag. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/117307 * tree-vect-data-refs.cc (vect_analyze_data_ref_accesses): Properly compute STMT_VINFO_SLP_VECT_ONLY. Set it on all parts of a split group. * gcc.dg/vect/pr117307.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr117307.c | 17 +++++++++++++++++ gcc/tree-vect-data-refs.cc | 19 +++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr117307.c diff --git a/gcc/testsuite/gcc.dg/vect/pr117307.c b/gcc/testsuite/gcc.dg/vect/pr117307.c new file mode 100644 index 00000000000..dc853d61706 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr117307.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=x86-64-v4" { target { x86_64-*-* i?86-*-* } } } */ + +int a; +float *b, *c; +float d; +void e() { + for (; a; a++) { + if (d) { + c[0] = b[0]; + c[1] = b[1]; + } else if (b[1]) + c[0] = b[0] * 0; + b += 2; + c += 2; + } +} diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc index 202af7a8952..54ad5c8f3dc 100644 --- a/gcc/tree-vect-data-refs.cc +++ b/gcc/tree-vect-data-refs.cc @@ -3565,12 +3565,15 @@ vect_analyze_data_ref_accesses (vec_info *vinfo, DR_GROUP_NEXT_ELEMENT (lastinfo) = stmtinfo_b; lastinfo = stmtinfo_b; - STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a) - = !can_group_stmts_p (stmtinfo_a, stmtinfo_b, false); + if (! STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a)) + { + STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a) + = !can_group_stmts_p (stmtinfo_a, stmtinfo_b, false); - if (dump_enabled_p () && STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a)) - dump_printf_loc (MSG_NOTE, vect_location, - "Load suitable for SLP vectorization only.\n"); + if (dump_enabled_p () && STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a)) + dump_printf_loc (MSG_NOTE, vect_location, + "Load suitable for SLP vectorization only.\n"); + } if (init_b == init_prev && !to_fixup.add (DR_GROUP_FIRST_ELEMENT (stmtinfo_a)) @@ -3614,7 +3617,11 @@ vect_analyze_data_ref_accesses (vec_info *vinfo, { DR_GROUP_NEXT_ELEMENT (g) = DR_GROUP_NEXT_ELEMENT (next); if (!newgroup) - newgroup = next; + { + newgroup = next; + STMT_VINFO_SLP_VECT_ONLY (newgroup) + = STMT_VINFO_SLP_VECT_ONLY (grp); + } else DR_GROUP_NEXT_ELEMENT (ng) = next; ng = next;