public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/79349] unused std::string is not optimized away in presense of a call
       [not found] <bug-79349-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-26 23:17 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: pinskia at gcc dot gnu.org @ 2021-12-26 23:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libstdc++                   |tree-optimization

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is the current IR (with -fno-exceptions) at -O3:

  MEM[(struct basic_string *)&s] ={v} {CLOBBER};
  MEM[(struct _Alloc_hider *)&s] ={v} {CLOBBER};
  MEM[(struct _Alloc_hider *)&s]._M_p = &s.D.26433._M_local_buf;
  __builtin_memcpy (&s.D.26433._M_local_buf, "abc", 3);
  s._M_string_length = 3;
  MEM[(char_type &)&s + 19] = 0;
  foo ();
  _3 = s._M_dataplus._M_p;
  if (&s.D.26433._M_local_buf != _3)
    goto <bb 3>; [53.47%]
  else
    goto <bb 4>; [46.53%]

  <bb 3> [local count: 574129753]:
  _7 = s.D.26433._M_allocated_capacity;
  _8 = _7 + 1;
  operator delete (_3, _8);

for some reason GCC thinks foo can modify s so the load for s._M_dataplus._M_p
is not be optimized to just &s.D.26433._M_local_buf

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-26 23:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-79349-4@http.gcc.gnu.org/bugzilla/>
2021-12-26 23:17 ` [Bug tree-optimization/79349] unused std::string is not optimized away in presense of a call 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).