From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id A6BBA3858412; Wed, 26 Apr 2023 09:33:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6BBA3858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682501635; bh=yLfTZBEv0T7ZAzsGBUrXVJWF4YsFEbbwHUawQrLB+cA=; h=From:To:Subject:Date:From; b=rlWhSo6tHTAQR8YkX8UtzPiX7EFOiJHtAK5p1w/4+0uaTa+v9I1JPV1heKCFZHXyo OQruMDpjmP+TRwx+cipOh1ZoTraGvrUf/UDg7qYK9fRiQVmQO7YLyTZ+d9nuhc7/uQ 9Qz908dwpDAKScGqimYlbfeR+E5xxKcKQA5lRnr8= 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 r13-7251] rtl-optimization/109585 - alias analysis typo X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: 263d1ed0484fc81d3f93e39cdd2f9eb0ce4d3e88 X-Git-Newrev: bb406a6aea336966681927a27f54ee89c4fd4ea1 Message-Id: <20230426093355.A6BBA3858412@sourceware.org> Date: Wed, 26 Apr 2023 09:33:55 +0000 (GMT) List-Id: https://gcc.gnu.org/g:bb406a6aea336966681927a27f54ee89c4fd4ea1 commit r13-7251-gbb406a6aea336966681927a27f54ee89c4fd4ea1 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 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,