public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "user202729 at protonmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/110137] implement clang -fassume-sane-operator-new
Date: Mon, 27 May 2024 03:07:38 +0000	[thread overview]
Message-ID: <bug-110137-4-d1q0o0MWM9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110137-4@http.gcc.gnu.org/bugzilla/>

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

user202729 <user202729 at protonmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |user202729 at protonmail dot com

--- Comment #6 from user202729 <user202729 at protonmail dot com> ---
Created attachment 58293
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58293&action=edit
Proposed implementation.

I've implement it. (Attached patch) It would be helpful if someone can review
it.

Some notes:

1. Clang's documentation says the effect of `-fassume-sane-operator-new` is to
assume no-alias, but it is pointed out that Clang also assumes no-side-effect.
So I explicitly state that in the documentation.
2. The original intent is to fix
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110035 .

While this patch alone is insufficient to fix that (as explained in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110035#c17 ), it would be
sufficient to improve the performance of the following (to only load from
global memory once):

```
int a;

// Prevent optimization
void sink(void *m) {
    asm volatile("" : : "g"(m) : "memory");
}

int f(){
        int x=a;
        float* z=new float;
        int y=a;
        int result=x+y;
        sink(z);
        return result;
}
```

3. I'm not sure which additional optimizations can be done if we know something
is pure, but this would improve that one case. Other cases can be added later
on.

  parent reply	other threads:[~2024-05-27  3:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06  8:15 [Bug c++/110137] New: " rguenth at gcc dot gnu.org
2023-06-06  8:17 ` [Bug c++/110137] " rguenth at gcc dot gnu.org
2023-06-09 12:22 ` redi at gcc dot gnu.org
2023-08-02  4:20 ` hiraditya at msn dot com
2023-08-02  6:56 ` redi at gcc dot gnu.org
2023-08-02  8:24 ` rguenther at suse dot de
2024-05-27  3:07 ` user202729 at protonmail dot com [this message]
2024-05-27  7:47 ` redi at gcc dot gnu.org
2024-06-04 10:16 ` user202729 at protonmail dot com
2024-06-04 10:39 ` hubicka at ucw dot cz
2024-06-04 11:31 ` redi at gcc dot gnu.org
2024-06-04 11:37 ` redi at gcc dot gnu.org
2024-06-04 11:45 ` jakub at gcc dot gnu.org
2024-06-04 11:57   ` Jan Hubicka
2024-06-04 11:57 ` hubicka at ucw dot cz
2024-06-05  8:23 ` user202729 at protonmail dot com
2024-06-05 13:00 ` hubicka at ucw dot cz
2024-06-23 18:14 ` user202729 at protonmail dot com

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-110137-4-d1q0o0MWM9@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).