From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 9DE033858404; Tue, 25 Apr 2023 12:24:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DE033858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682425456; bh=5L4+wZ+NiTxOYWONukHcwADQuMa2DjcWtKNeaoMJgiA=; h=From:To:Subject:Date:From; b=gf4/9JDFXQjLH1Hs2XmZxErkpcWbmhLhLvUt0DKdi7LSuKWjmI1DXOrHS8e9tIyv9 Yb8VS4RaBOZ15mpgYHAVSdJ2Jfm+0YGAIpIZTSd/wQoQjSnuif16he4WLPROBd5Sxh gg3X6y87aY5SyCah8atYPl0sGAkrmmZkskkN+4OE= 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 r14-219] rtl-optimization/109585 - alias analysis typo X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 97f8f2d0a0384d377ca46da88495f9a3d18d4415 X-Git-Newrev: 6d4bd27a60447c7505cb4783e675e98a191a8904 Message-Id: <20230425122416.9DE033858404@sourceware.org> Date: Tue, 25 Apr 2023 12:24:16 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6d4bd27a60447c7505cb4783e675e98a191a8904 commit r14-219-g6d4bd27a60447c7505cb4783e675e98a191a8904 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. 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,