public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/71258] Missed optimizations: dynamic allocation, virtual calls, empty destructors
       [not found] <bug-71258-4@http.gcc.gnu.org/bugzilla/>
@ 2024-03-18  6:48 ` pinskia at gcc dot gnu.org
  2024-03-18  6:51 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-18  6:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 57722
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57722&action=edit
testcase

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/71258] Missed optimizations: dynamic allocation, virtual calls, empty destructors
       [not found] <bug-71258-4@http.gcc.gnu.org/bugzilla/>
  2024-03-18  6:48 ` [Bug tree-optimization/71258] Missed optimizations: dynamic allocation, virtual calls, empty destructors pinskia at gcc dot gnu.org
@ 2024-03-18  6:51 ` pinskia at gcc dot gnu.org
  2024-03-19 19:28 ` phosit at autistici dot org
  2024-03-19 19:37 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-18  6:51 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
  _5 = operator new (16);
  MEM[(struct __as_base  &)_5] ={v} {CLOBBER(bob)};
  MEM[(struct model *)_5].D.38294._vptr.concept = &MEM <int (*) ()[5]> [(void
*)&_ZTVN4poly5modelIiEE + 16B];
  MEM[(struct model *)_5]._data = 40;
  _6 = operator new (16);

  <bb 3> [local count: 1073741824]:
  MEM[(struct __as_base  &)_6] ={v} {CLOBBER(bob)};
  MEM[(struct model *)_6].D.41483._vptr.concept = &MEM <int (*) ()[5]> [(void
*)&_ZTVN4poly5modelIfEE + 16B];
  MEM[(struct model *)_6]._data = 2.0e+0;
  _7 = MEM[(struct concept *)_5]._vptr.concept;

Basically the second `operator new` is treated as being able to touch the
pointer that is returned the first `operator new`.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/71258] Missed optimizations: dynamic allocation, virtual calls, empty destructors
       [not found] <bug-71258-4@http.gcc.gnu.org/bugzilla/>
  2024-03-18  6:48 ` [Bug tree-optimization/71258] Missed optimizations: dynamic allocation, virtual calls, empty destructors pinskia at gcc dot gnu.org
  2024-03-18  6:51 ` pinskia at gcc dot gnu.org
@ 2024-03-19 19:28 ` phosit at autistici dot org
  2024-03-19 19:37 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: phosit at autistici dot org @ 2024-03-19 19:28 UTC (permalink / raw)
  To: gcc-bugs

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

Phosit <phosit at autistici dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |phosit at autistici dot org

--- Comment #5 from Phosit <phosit at autistici dot org> ---
struct Base{
    virtual ~Base() = default;
};

int main(){
    delete new Base;
    return 0;
}

In this partial test case the destructor is not inlined.
Curiously when changing the function name the destructor is inlined.
I compiled with -O3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/71258] Missed optimizations: dynamic allocation, virtual calls, empty destructors
       [not found] <bug-71258-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2024-03-19 19:28 ` phosit at autistici dot org
@ 2024-03-19 19:37 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-19 19:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Phosit from comment #5)
> struct Base{
>     virtual ~Base() = default;
> };
> 
> int main(){
>     delete new Base;
>     return 0;
> }
> 
> In this partial test case the destructor is not inlined.
> Curiously when changing the function name the destructor is inlined.
> I compiled with -O3

Yes main is known to be only called once so heuristics decide inlining is not
profitable. Gcc does this because things called directly from main (without a
loop) is usually not on the hot path of applications.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-19 19:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-71258-4@http.gcc.gnu.org/bugzilla/>
2024-03-18  6:48 ` [Bug tree-optimization/71258] Missed optimizations: dynamic allocation, virtual calls, empty destructors pinskia at gcc dot gnu.org
2024-03-18  6:51 ` pinskia at gcc dot gnu.org
2024-03-19 19:28 ` phosit at autistici dot org
2024-03-19 19:37 ` pinskia at gcc dot gnu.org

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).