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.