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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
                 CC|                            |rguenth at gcc dot gnu.org
          Component|c++                         |libstdc++

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
This is because it still needs to generate the std::string objects at the
caller
site (outside of the if (print)).  This involves quite some code to get
rid of, and even at -O3 we do not inline basic_string::basic_string it seems
(ISTR that is out-of-line in the library):

  __asm__ __volatile__("mfence" :  :  : "memory");
  _6 = MEM[(const int *)&data + 4B];
  if (_6 > 0)
    goto <bb 3>; [41.48%]
  else
    goto <bb 11>; [58.52%]

  <bb 3> [local count: 445388109]:
  std::basic_string<char>::basic_string (&D.39204, "<", &D.39205);
  _7 = MEM[(char * *)&D.39204];
  _8 = _7 + 18446744073709551592;
  if (_8 != &_S_empty_rep_storage)
    goto <bb 5>; [10.00%]
  else
    goto <bb 4>; [90.00%]

  <bb 4> [local count: 434030711]:
  goto <bb 10>; [100.00%]

  <bb 5> [local count: 44538811]:
  if (__gthrw___pthread_key_create != 0B)
    goto <bb 6>; [53.47%]
  else
    goto <bb 7>; [46.53%]

  <bb 6> [local count: 23814902]:
  _9 = &MEM[(struct _Rep *)_7 + -24B].D.23940._M_refcount;
  _10 = __atomic_fetch_add_4 (_9, 4294967295, 4);
  _11 = (int) _10;
  goto <bb 8>; [100.00%]

  <bb 7> [local count: 20723909]:
  __result_12 = MEM[(_Atomic_word *)_7 + -8B];
  _13 = __result_12 + -1;
  MEM[(_Atomic_word *)_7 + -8B] = _13;

  <bb 8> [local count: 44538811]:
  # _14 = PHI <_11(6), __result_12(7)>
  if (_14 <= 0)
    goto <bb 9>; [25.50%]
  else
    goto <bb 4>; [74.50%]

  <bb 9> [local count: 11357397]:
  std::basic_string<char>::_Rep::_M_destroy (_8, &D.39206);

  <bb 10> [local count: 445388108]:
  D.39206 ={v} {CLOBBER};
  D.39204 ={v} {CLOBBER};
  D.39205 ={v} {CLOBBER};

  <bb 11> [local count: 1073741825]:
  __asm__ __volatile__("mfence" :  :  : "memory");
  data ={v} {CLOBBER};

Reply via email to