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/113106] Missing CSE with cast to volatile
Date: Thu, 21 Dec 2023 13:29:12 +0000	[thread overview]
Message-ID: <bug-113106-4-LcGDsTn0KK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113106-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |rtl-optimization
     Ever confirmed|0                           |1
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2023-12-21
             Status|UNCONFIRMED                 |NEW

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Uroš Bizjak from comment #4)
> (In reply to Richard Biener from comment #3)
> > The situation with address-spaces isn't valid as we need to preserve the
> > second load because it's volatile.  I think we simply refuse to combine
> > volatile loads out of caution in the first case.
> 
> int __seg_gs b;
> return *(volatile __seg_gs int *) &b + b;
> 
> But the above is the same w.r.t to volatile as:
> 
> int a;
> return *(volatile int *) &a + a;
> 
> ?
> 
> BTW: I also checked with clang, and it creates expected code in all cases.

But you don't get

       movl    %gs:b(%rip), %eax
       addl    %eax, %eax

or

       movl    b(%rip), %eax
       addl    %eax, %eax

which I think would be wrong.  The volatile access doesn't need to yield
the same value as the non-volatile one so we can't value-number them the
same.

The combine issue remains of course.  But GCCs point was always that
trying to optimize volatile is wasted time.

  parent reply	other threads:[~2023-12-21 13:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 10:38 [Bug c/113106] New: " ubizjak at gmail dot com
2023-12-21 10:41 ` [Bug c/113106] " ubizjak at gmail dot com
2023-12-21 10:44 ` ubizjak at gmail dot com
2023-12-21 12:50 ` rguenth at gcc dot gnu.org
2023-12-21 12:57 ` ubizjak at gmail dot com
2023-12-21 13:02 ` ubizjak at gmail dot com
2023-12-21 13:29 ` rguenth at gcc dot gnu.org [this message]
2023-12-21 15:08 ` [Bug rtl-optimization/113106] " ubizjak at gmail dot com
2023-12-21 15:11 ` 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-113106-4-LcGDsTn0KK@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).