From patchwork Tue Jan 4 09:16:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1575137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Be/dj6L+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSn7T0wvjz9sP7 for ; Tue, 4 Jan 2022 20:17:07 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6FD843858421 for ; Tue, 4 Jan 2022 09:17:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FD843858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641287824; bh=zR7RhG59rBFmfp9cOYQsxRuDDIQ6VUMybaoNtfwIAQA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Be/dj6L+ciFfeSwQPaf+GiQ4b0MUk/Agyv5fFyXStiaVLAgrTNtoDvJ7jULZcmeGP bDdqw5ivxMvu02gL6M/poqHF/HrbEqA5eqHMiYDAL+la1VnRf6kwaXOXSRY6RCUPH9 Ji2s/HMODFHLwesYdT7PyM1DHJwWiMBJLRXVLLrg= 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.220.29]) by sourceware.org (Postfix) with ESMTPS id 5FA163858D35 for ; Tue, 4 Jan 2022 09:16:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5FA163858D35 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 62D571F398 for ; Tue, 4 Jan 2022 09:16:22 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4FF7213AB2 for ; Tue, 4 Jan 2022 09:16:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ecdPEmYQ1GFYfwAAMHmgww (envelope-from ) for ; Tue, 04 Jan 2022 09:16:22 +0000 Date: Tue, 4 Jan 2022 10:16:21 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/103864 - SLP reduction of reductions with conversions Message-ID: <94o8qr6p-7o24-o6qn-1489-r89sor621rpo@fhfr.qr> MIME-Version: 1.0 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This generalizes the fix for PR103544 to also cover reductions that are not reduction chains and does not consider reductions wrapped in sign conversions for SLP reduction handling. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2022-01-04 Richard Biener PR tree-optimization/103864 PR tree-optimization/103544 * tree-vect-slp.c (vect_analyze_slp_instance): Exclude reductions wrapped in conversions from SLP handling. (vect_analyze_slp): Revert PR103544 change. * gcc.dg/vect/pr103864.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr103864.c | 16 ++++++++++++++++ gcc/tree-vect-slp.c | 18 +++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr103864.c diff --git a/gcc/testsuite/gcc.dg/vect/pr103864.c b/gcc/testsuite/gcc.dg/vect/pr103864.c new file mode 100644 index 00000000000..464d5731a42 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr103864.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -fno-tree-reassoc" } */ + +void +crash_me (short int *crash_me_result, int i, char crash_me_ptr_0) +{ + while (i < 1) + { + int j; + + for (j = 0; j < 2; ++j) + crash_me_result[j] += crash_me_ptr_0 + 1; + + i += 3; + } +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 3566752c657..c3a1681d7c6 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3325,8 +3325,13 @@ vect_analyze_slp_instance (vec_info *vinfo, = as_a (vinfo)->reductions; scalar_stmts.create (reductions.length ()); for (i = 0; reductions.iterate (i, &next_info); i++) - if (STMT_VINFO_RELEVANT_P (next_info) - || STMT_VINFO_LIVE_P (next_info)) + if ((STMT_VINFO_RELEVANT_P (next_info) + || STMT_VINFO_LIVE_P (next_info)) + /* ??? Make sure we didn't skip a conversion around a reduction + path. In that case we'd have to reverse engineer that conversion + stmt following the chain using reduc_idx and from the PHI + using reduc_def. */ + && STMT_VINFO_DEF_TYPE (next_info) == vect_reduction_def) scalar_stmts.quick_push (next_info); /* If less than two were relevant/live there's nothing to SLP. */ if (scalar_stmts.length () < 2) @@ -3419,13 +3424,8 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) vinfo = next; } STMT_VINFO_DEF_TYPE (first_element) = vect_internal_def; - /* It can be still vectorized as part of an SLP reduction. - ??? But only if we didn't skip a conversion around the group. - In that case we'd have to reverse engineer that conversion - stmt following the chain using reduc_idx and from the PHI - using reduc_def. */ - if (STMT_VINFO_DEF_TYPE (last) == vect_reduction_def) - loop_vinfo->reductions.safe_push (last); + /* It can be still vectorized as part of an SLP reduction. */ + loop_vinfo->reductions.safe_push (last); } /* Find SLP sequences starting from groups of reductions. */