public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sandra at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/93946] Bogus redundant store removal
Date: Mon, 06 Apr 2020 05:35:45 +0000	[thread overview]
Message-ID: <bug-93946-4-pP6jhypjPw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-93946-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #15 from sandra at gcc dot gnu.org ---
Hmmm.  I've gone over this code 2 or 3 times now, and I'm still convinced the
problem is in the alias analysis, not the scheduler.

I've stepped deeper into the code in the debugger, and here is the backtrace
from where I see things going wrong:

#0  indirect_refs_may_alias_p (ref1=0x7ffff74196f0, base1=0x7ffff73fec08, 
    offset1=..., max_size1=..., size1=..., ref1_alias_set=1, 
    base1_alias_set=4, ref2=0x7ffff74195d0, base2=0x7ffff73febb8, offset2=..., 
    max_size2=..., size2=..., ref2_alias_set=1, base2_alias_set=6, tbaa_p=true)
    at /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/tree-ssa-alias.c:2122
#1  0x00000000013f8266 in refs_may_alias_p_2 (ref1=0x7fffffffd7d0, 
    ref2=0x7fffffffd790, tbaa_p=true)
    at /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/tree-ssa-alias.c:2320
#2  0x00000000013f82bb in refs_may_alias_p_1 (ref1=0x7fffffffd7d0, 
    ref2=0x7fffffffd790, tbaa_p=true)
    at /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/tree-ssa-alias.c:2339
#3  0x0000000000b90b06 in rtx_refs_may_alias_p (x=0x7ffff742cac8, 
    mem=0x7ffff742c9a8, tbaa_p=true)
    at /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/alias.c:365
#4  0x0000000000b981de in true_dependence_1 (mem=0x7ffff742c9a8, 
    mem_mode=E_SImode, mem_addr=0x7ffff742c7e0, x=0x7ffff742cac8, 
    x_addr=0x7ffff742c798, mem_canonicalized=false)
    at /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/alias.c:3048

The code here says

  /* Do type-based disambiguation.  */
  if (base1_alias_set != base2_alias_set
      && !alias_sets_conflict_p (base1_alias_set, base2_alias_set))
    return false;

and the "false" return status gets propagated all the way back up to
true_dependence.

It seems to me that what is going wrong is that it is failing to consider that
two pointer parameters can be aliased no matter what their declared type is,
and no matter what types they are cast to -- e.g. because they point to members
of the same union.  Should ao_ref_base_alias_set be putting everything based on
pointer parameters without restrict semantics into the same alias set, maybe? 
Or should there be some code in indirect_refs_may_alias_p to look for this
situation before it reaches the point of type-based disambiguation where it is
currently failing to DTRT?

  parent reply	other threads:[~2020-04-06  5:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-93946-4@http.gcc.gnu.org/bugzilla/>
2020-03-24 17:51 ` sandra at gcc dot gnu.org
2020-03-25  7:21 ` rguenth at gcc dot gnu.org
2020-03-27 20:19 ` sandra at gcc dot gnu.org
2020-03-28  7:38 ` rguenther at suse dot de
2020-03-28 22:41 ` sandra at gcc dot gnu.org
2020-03-30  6:43 ` rguenth at gcc dot gnu.org
2020-04-06  5:35 ` sandra at gcc dot gnu.org [this message]
2020-04-06  7:49 ` rguenth at gcc dot gnu.org
2020-04-06  8:08 ` rguenth at gcc dot gnu.org
2020-04-08  2:30 ` sandra at gcc dot gnu.org
2020-04-08  6:20 ` rguenth at gcc dot gnu.org
2020-04-08 12:04 ` rguenth at gcc dot gnu.org
2020-04-08 17:28 ` cvs-commit at gcc dot gnu.org
2020-04-09  2:25 ` sandra 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-93946-4-pP6jhypjPw@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).