From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id C1F4F3858281 for ; Tue, 21 Jun 2022 17:46:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C1F4F3858281 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 968C11F8DC for ; Tue, 21 Jun 2022 17:46:33 +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 7974E13A88 for ; Tue, 21 Jun 2022 17:46:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0DaZHfkDsmJSMAAAMHmgww (envelope-from ) for ; Tue, 21 Jun 2022 17:46:33 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] data-ref: Improve non-loop disambiguation [PR106019] Date: Tue, 21 Jun 2022 19:46:32 +0200 Message-Id: References: In-Reply-To: To: Richard Sandiford via Gcc-patches X-Mailer: iPhone Mail (19F77) X-Spam-Status: No, score=-11.7 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, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2022 17:46:38 -0000 > Am 21.06.2022 um 17:16 schrieb Richard Sandiford via Gcc-patches : >=20 > =EF=BB=BFWhen dr_may_alias_p is called without a loop context, it tries > to use the tree-affine interface to calculate the difference > between the two addresses and use that difference to check whether > the gap between the accesses is known at compile time. However, as the > example in the PR shows, this doesn't expand SSA_NAMEs and so can easily > be defeated by things like reassociation. >=20 > One fix would have been to use aff_combination_expand to expand the > SSA_NAMEs, but we'd then need some way of maintaining the associated > cache. This patch instead reuses the innermost_loop_behavior fields > (which exist even when no loop context is provided). >=20 > It might still be useful to do the aff_combination_expand thing too, > if an example turns out to need it. >=20 > Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? >=20 Ok. Thanks, Richard=20 > Richard >=20 >=20 > gcc/ > PR tree-optimization/106019 > * tree-data-ref.cc (dr_may_alias_p): Try using the > innermost_loop_behavior to disambiguate non-loop queries. >=20 > gcc/testsuite/ > PR tree-optimization/106019 > * gcc.dg/vect/bb-slp-pr106019.c: New test. > --- > gcc/testsuite/gcc.dg/vect/bb-slp-pr106019.c | 15 +++++++++++++++ > gcc/tree-data-ref.cc | 19 +++++++++++++++++++ > 2 files changed, 34 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr106019.c >=20 > diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr106019.c b/gcc/testsuite/g= cc.dg/vect/bb-slp-pr106019.c > new file mode 100644 > index 00000000000..218d7cca33d > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr106019.c > @@ -0,0 +1,15 @@ > +/* { dg-do compile } */ > + > +void f(double *p, long i) > +{ > + p[i+0] +=3D 1; > + p[i+1] +=3D 1; > +} > +void g(double *p, long i) > +{ > + double *q =3D p + i; > + q[0] +=3D 1; > + q[1] +=3D 1; > +} > + > +/* { dg-final { scan-tree-dump-not "can't determine dependence" slp2 } } *= / > diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc > index 8b7edf2124a..90242948c27 100644 > --- a/gcc/tree-data-ref.cc > +++ b/gcc/tree-data-ref.cc > @@ -2968,6 +2968,25 @@ dr_may_alias_p (const struct data_reference *a, con= st struct data_reference *b, > disambiguation. */ > if (!loop_nest) > { > + tree tree_size_a =3D TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (a))); > + tree tree_size_b =3D TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (b))); > + > + if (DR_BASE_ADDRESS (a) > + && DR_BASE_ADDRESS (b) > + && operand_equal_p (DR_BASE_ADDRESS (a), DR_BASE_ADDRESS (b)) > + && operand_equal_p (DR_OFFSET (a), DR_OFFSET (b)) > + && poly_int_tree_p (tree_size_a) > + && poly_int_tree_p (tree_size_b) > + && !ranges_maybe_overlap_p (wi::to_widest (DR_INIT (a)), > + wi::to_widest (tree_size_a), > + wi::to_widest (DR_INIT (b)), > + wi::to_widest (tree_size_b))) > + { > + gcc_assert (integer_zerop (DR_STEP (a)) > + && integer_zerop (DR_STEP (b))); > + return false; > + } > + > aff_tree off1, off2; > poly_widest_int size1, size2; > get_inner_reference_aff (DR_REF (a), &off1, &size1); > --=20 > 2.25.1 >=20