[Bug tree-optimization/110819] Missed optimization: when vector's size is 0 but vector::reserve has been called.

2023-07-29 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110819

Xi Ruoyao  changed:

   What|Removed |Added

 CC||xry111 at gcc dot gnu.org

--- Comment #3 from Xi Ruoyao  ---
(In reply to AK from comment #2)
> > When compiled with clang, libstdc++'s std::vector uses 
> > __builtin_operator_new which always has the -fassume-sane-operator-new 
> > semantics, and so can be optimized.
> 
> yes clang optimizes with libstdc++ as well. what can be done in gcc for it
> to detect that the new+delete pair can be optimized away?

Basically we'll need __builtin_operator_new.  See all the "see also" links.

[Bug tree-optimization/110819] Missed optimization: when vector's size is 0 but vector::reserve has been called.

2023-07-28 Thread hiraditya at msn dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110819

--- Comment #2 from AK  ---
> When compiled with clang, libstdc++'s std::vector uses __builtin_operator_new 
> which always has the -fassume-sane-operator-new semantics, and so can be 
> optimized.

yes clang optimizes with libstdc++ as well. what can be done in gcc for it to
detect that the new+delete pair can be optimized away?

[Bug tree-optimization/110819] Missed optimization: when vector's size is 0 but vector::reserve has been called.

2023-07-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110819

Jonathan Wakely  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=110137

--- Comment #1 from Jonathan Wakely  ---
I guess gcc can't optimize this away because it doesn't know if operator new
has side effects. When compiled with clang, libstdc++'s std::vector uses
__builtin_operator_new which always has the -fassume-sane-operator-new
semantics, and so can be optimized.

[Bug tree-optimization/110819] Missed optimization: when vector's size is 0 but vector::reserve has been called.

2023-07-26 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110819

Andrew Pinski  changed:

   What|Removed |Added

  Component|c++ |tree-optimization
   Keywords||missed-optimization
   Severity|normal  |enhancement