public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/109585] [10/11/12/13/14 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
Date: Mon, 24 Apr 2023 09:54:35 +0000	[thread overview]
Message-ID: <bug-109585-4-NbTlL6vvKR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109585-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585

--- Comment #21 from Richard Biener <rguenth at gcc dot gnu.org> ---
aliasing_component_refs_p seems to try handle trailing arrays via
component_ref_to_zero_sized_trailing_array_p.  It properly detects

f_5->fam[0].n

but fails on

MEM[(struct P *)f_3(D) + 8B].n

but it would also in all cases happily continue with the base ref type
when comparing sizes:

  /* Now search for the type1 in the access path of ref2.  This
     would be a common base for doing offset based disambiguation on.
     This however only makes sense if type2 is big enough to hold type1.  */
  int cmp_outer = compare_type_sizes (type2, type1);

I also wonder if

  /* 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))

here type1 shouldn't be type2?

In any case we end up failing the access_path_may_continue_p checks and
disambiguate.

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,

seems to fix the testcase - can anybody confirm?

Honza, is that indeed a typo or do I just hide the issue?

  parent reply	other threads:[~2023-04-24  9:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
2023-04-21 10:40 ` [Bug c/109585] " hector at marcansoft dot com
2023-04-21 10:52 ` rguenth at gcc dot gnu.org
2023-04-21 11:36 ` [Bug target/109585] " hector at marcansoft dot com
2023-04-21 11:37 ` hector at marcansoft dot com
2023-04-21 16:36 ` hector at marcansoft dot com
2023-04-21 16:38 ` hector at marcansoft dot com
2023-04-21 16:43 ` pinskia at gcc dot gnu.org
2023-04-21 16:50 ` [Bug middle-end/109585] " pinskia at gcc dot gnu.org
2023-04-21 16:55 ` hector at marcansoft dot com
2023-04-21 17:05 ` pinskia at gcc dot gnu.org
2023-04-21 17:08 ` hector at marcansoft dot com
2023-04-21 17:16 ` [Bug middle-end/109585] Carla/sord miscompiled with -O2 on ARM64 with flexible array member pinskia at gcc dot gnu.org
2023-04-22 21:48 ` [Bug rtl-optimization/109585] " amonakov at gcc dot gnu.org
2023-04-23  7:06 ` sjames at gcc dot gnu.org
2023-04-23  7:08 ` hector at marcansoft dot com
2023-04-23  7:50 ` xry111 at gcc dot gnu.org
2023-04-23  7:55 ` [Bug rtl-optimization/109585] [10/11/12/13/14 regression] " xry111 at gcc dot gnu.org
2023-04-24  6:39 ` rguenth at gcc dot gnu.org
2023-04-24  6:40 ` rguenth at gcc dot gnu.org
2023-04-24  8:46 ` amonakov at gcc dot gnu.org
2023-04-24  9:04 ` jakub at gcc dot gnu.org
2023-04-24  9:54 ` rguenth at gcc dot gnu.org [this message]
2023-04-24 11:35 ` rguenth at gcc dot gnu.org
2023-04-25 12:24 ` cvs-commit at gcc dot gnu.org
2023-04-25 12:25 ` [Bug rtl-optimization/109585] [10/11/12/13 " rguenth at gcc dot gnu.org
2023-04-26  9:33 ` cvs-commit at gcc dot gnu.org
2023-04-26 10:41 ` cvs-commit at gcc dot gnu.org
2023-05-02 12:04 ` [Bug rtl-optimization/109585] [10/11 " cvs-commit at gcc dot gnu.org
2023-07-07 10:08 ` [Bug rtl-optimization/109585] [10 " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109585-4-NbTlL6vvKR@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).