From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id B2CFD3857712; Wed, 26 Apr 2023 10:41:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2CFD3857712 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682505680; bh=kXlRbX2ho6E8FPCaRksXAOHh6U+/PfTNZh16pMM9+KE=; h=From:To:Subject:Date:From; b=UkiPfEz6Sb05EqD/RIRDLwvxxWNOqaRxfzog5mogupbev5Ua1XCkG1adD7AEDu72e oZoUSRM+e0qhIGCAc7/e+Jxp/LfIMLIOq0p3F1jLLurOfJmsSEoDw5sXBniHKLCra5 qqRWNVvwT5XhzEsGqHMOk4ZyLFYSpR3RYJPgPCKE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-9473] rtl-optimization/109585 - alias analysis typo X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: c7de861c609573b1f219fcdf6c683612c987621f X-Git-Newrev: ef6051b36241bf130bf76af0b775248635dc616e Message-Id: <20230426104120.B2CFD3857712@sourceware.org> Date: Wed, 26 Apr 2023 10:41:20 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ef6051b36241bf130bf76af0b775248635dc616e commit r12-9473-gef6051b36241bf130bf76af0b775248635dc616e Author: Richard Biener Date: Mon Apr 24 13:31:07 2023 +0200 rtl-optimization/109585 - alias analysis typo 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. PR rtl-optimization/109585 * tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo. * gcc.dg/torture/pr109585.c: New testcase. (cherry picked from commit 6d4bd27a60447c7505cb4783e675e98a191a8904) Diff: --- gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++++++++++ gcc/tree-ssa-alias.cc | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) 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 b1e7a2d5afc..be7b597266f 100644 --- a/gcc/tree-ssa-alias.cc +++ b/gcc/tree-ssa-alias.cc @@ -1326,7 +1326,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,