public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mhillen at linux dot ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/92294] alias attribute generates incorrect code
Date: Thu, 19 Nov 2020 13:02:42 +0000	[thread overview]
Message-ID: <bug-92294-4-j5IVqNaf0t@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-92294-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Marius Hillenbrand <mhillen at linux dot ibm.com> ---
>From my current understanding, gcc addresses a and b in two different ways,
which is not handled correctly by the dependency analysis / alias analysis
while employed by the cse1 pass, and then causes cse1 to incorrectly eliminate
the read from b (reusing the const 1 from b=1).

the rtl addresses a via the section anchor yet b via its symbol reference:

b = 1 becomes
(set (reg/f:DI 62) (symbol_ref:DI ("b") [flags 0x602]  <var_decl .. b>))
(set (mem/c:SI (reg/f:DI 62) [1 b+0 S4 A32]) (const_int 1 [0x1]))

vs

a=2 becomes
(set (reg/f:DI 64) (symbol_ref:DI ("*.LANCHOR0") [flags 0x182]))
(set (mem/c:SI (plus:DI (reg/f:DI 64) (const_int 4 [0x4])) [1 a+0 S4 A32])
(const_int 2 [0x2]))

when visiting the write to a, cse1 should identify the aliasing and thus drop
the "remembered" b. for that, cse iterates its hash table and compares all
present MEM rtx to the new address (cse.c:invalidate()).

that step compares (canonicalized) addresses
(const:DI (plus:DI (symbol_ref:DI ("*.LANCHOR0") [flags 0x182]) (const_int 4
[0x4])))
and (symbol_ref:DI ("b") [flags 0x602]  <var_decl b>)

the comparison of these two (in alias.c:write_dependence_p()) falsely claims
that there is no anti-dependence between the two.

I am not certain yet how that comparison is supposed to work with section
anchors. It looks like we either fail to reconnect (anchor + 4) to the
symbol_ref of "a" (so we could identify both symbol_refs as equivalent) or lose
the offset relative to the anchor (so we could see that both have the same
offset relative to the anchor).

  parent reply	other threads:[~2020-11-19 13:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-92294-4@http.gcc.gnu.org/bugzilla/>
2020-05-07 11:56 ` jakub at gcc dot gnu.org
2020-07-23  6:51 ` rguenth at gcc dot gnu.org
2020-11-13  9:30 ` mhillen at linux dot ibm.com
2020-11-19 11:03 ` mhillen at linux dot ibm.com
2020-11-19 13:02 ` mhillen at linux dot ibm.com [this message]
2020-11-23 20:49 ` rsandifo at gcc dot gnu.org
2021-01-19 17:51 ` cvs-commit at gcc dot gnu.org
2021-01-19 17:53 ` rsandifo at gcc dot gnu.org
2022-02-11  9:13 ` pinskia 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-92294-4-j5IVqNaf0t@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).