From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id A08573858C74 for ; Tue, 25 Apr 2023 09:52:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A08573858C74 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 3DEE428A95C; Tue, 25 Apr 2023 11:52:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1682416362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8WsuWk6+Ju3hNfnFhKYsxloT2GTWr6uhEVpyhxis/5w=; b=bB1oer5YVE/LnMYl4EIqNuVryvuj74rgUIKP7FaAKOhh+EXA82XTBgG+AfEsZdU7YoVWYf 8lOwBCgEqCX5a5Zh6v1R//OKpUnuOYuIUFGLbSco6DjjBsipL0V3mraBC3snDpFC4vfF7f nL5P9zMHdsJ+HvqJQ7ZBtAtjka5Q1wU= Date: Tue, 25 Apr 2023 11:52:42 +0200 From: Jan Hubicka To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] rtl-optimization/109585 - alias analysis typo Message-ID: References: <20230425062543.851AF13466@imap2.suse-dmz.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230425062543.851AF13466@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 List-Id: > When r10-514-gc6b84edb6110dd2b4fb improved access path analysis > it introduced a typo that triggers when there's an access to a > trailing array in the first access path leading to false > disambiguation. > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > Honza, does this look OK? Yes, sorry for that - that is a nasty pasto :( Honza > > Thanks, > Richard. > > PR rtl-optimization/109585 > * tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo. > > * gcc.dg/torture/pr109585.c: New testcase. > --- > gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++ > gcc/tree-ssa-alias.cc | 2 +- > 2 files changed, 34 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/torture/pr109585.c > > diff --git a/gcc/testsuite/gcc.dg/torture/pr109585.c b/gcc/testsuite/gcc.dg/torture/pr109585.c > new file mode 100644 > index 00000000000..f92de7c1f2e > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/torture/pr109585.c > @@ -0,0 +1,33 @@ > +/* { dg-do run } */ > + > +#include > + > +struct P { > + long v; > + struct P *n; > +}; > + > +struct F { > + long x; > + struct P fam[]; > +}; > + > +int __attribute__((noipa)) > +f(struct F *f, int i) > +{ > + struct P *p = f->fam; > + asm("" : "+r"(f): "r"(p)); > + p->v = 0; > + p->n = 0; > + return f->fam->n != 0; > +} > + > +int > +main() > +{ > + struct F *m = malloc (sizeof (long) + 2 * sizeof (struct P)); > + m->fam[0].n = &m->fam[1]; > + if (f (m, 0)) > + abort (); > + return 0; > +} > diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc > index 81bc51ed4ad..8a1ec9091fa 100644 > --- a/gcc/tree-ssa-alias.cc > +++ b/gcc/tree-ssa-alias.cc > @@ -1330,7 +1330,7 @@ aliasing_component_refs_p (tree ref1, > /* If we didn't find a common base, try the other way around. */ > if (cmp_outer <= 0 > || (end_struct_ref1 > - && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0)) > + && compare_type_sizes (TREE_TYPE (end_struct_ref1), type2) <= 0)) > { > int res = aliasing_component_refs_walk (ref2, type2, base2, > offset2, max_size2, > -- > 2.35.3