From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 8439F3857820 for ; Thu, 10 Sep 2020 09:05:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8439F3857820 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=richard.sandiford@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3A6A4101E; Thu, 10 Sep 2020 02:05:03 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B9E3A3F68F; Thu, 10 Sep 2020 02:05:02 -0700 (PDT) From: Richard Sandiford To: Richard Biener Mail-Followup-To: Richard Biener , gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] fix useless unsharing of SLP tree References: Date: Thu, 10 Sep 2020 10:05:01 +0100 In-Reply-To: (Richard Biener's message of "Wed, 9 Sep 2020 14:46:03 +0200 (CEST)") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Thu, 10 Sep 2020 09:05:04 -0000 Richard Biener writes: > This avoids unsharing the SLP tree when optimizing load permutations > for reductions but there is no actual permute taking place. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. > > 2020-09-09 Richard Biener > > * tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Do > nothing when the permutation doesn't permute. Drive-by comment, sorry for not looking in more detail first, but: is there a difference in semantics between an identity load_permutation and a null load_permutation? Seems like it would be good to have a canonical form. Thanks, Richard > --- > gcc/tree-vect-slp.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c > index 03b11058bd5..15d57890b6f 100644 > --- a/gcc/tree-vect-slp.c > +++ b/gcc/tree-vect-slp.c > @@ -1905,11 +1905,14 @@ vect_attempt_slp_rearrange_stmts (slp_instance slp_instn) > } > > /* Check that the loads in the first sequence are different and there > - are no gaps between them. */ > + are no gaps between them and that there is an actual permutation. */ > + bool any_permute = false; > auto_sbitmap load_index (group_size); > bitmap_clear (load_index); > FOR_EACH_VEC_ELT (node->load_permutation, i, lidx) > { > + if (lidx != i) > + any_permute = true; > if (lidx >= group_size) > return false; > if (bitmap_bit_p (load_index, lidx)) > @@ -1917,6 +1920,8 @@ vect_attempt_slp_rearrange_stmts (slp_instance slp_instn) > > bitmap_set_bit (load_index, lidx); > } > + if (!any_permute) > + return false; > for (i = 0; i < group_size; i++) > if (!bitmap_bit_p (load_index, i)) > return false;