[Bug libstdc++/86590] Codegen is poor when passing std::string by value with _GLIBCXX_EXTERN_TEMPLATE undefined
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jul 20 08:47:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86590
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-07-20
Ever confirmed|0 |1
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we could try to somehow pattern-match this
"is-this-string-compile-time-constant" test or add a
__builtin_cstring_constant_p () ... after all we
end up evaluating this to false in the end, using __builtin_strlen but
then passing it the constant and folding it anyway.
<bb 3> [local count: 10037315480]:
# __s_63 = PHI <"Hello world"(2), __s_66(5)>
_64 = *__s_63;
_65 = __builtin_constant_p (_64);
if (_65 == 0)
goto <bb 6>; [5.50%]
else
goto <bb 4>; [94.50%]
<bb 4> [local count: 9485263123]:
if (_64 == 0)
goto <bb 6>; [5.50%]
else
goto <bb 5>; [94.50%]
<bb 5> [local count: 8963573645]:
__s_66 = __s_63 + 1;
goto <bb 3>; [100.00%]
<bb 6> [local count: 1073741826]:
# _67 = PHI <_65(3), _65(4)>
if (_67 != 0)
goto <bb 7>; [50.00%]
else
goto <bb 9>; [50.00%]
<bb 7> [local count: 4880644630]:
# __i_68 = PHI <0(6), __i_71(8)>
_69 = "Hello world" + __i_68;
_70 = *_69;
if (_70 != 0)
goto <bb 8>; [89.00%]
else
goto <bb 10>; [11.00%]
<bb 8> [local count: 4343773717]:
__i_71 = __i_68 + 1;
goto <bb 7>; [100.00%]
<bb 9> [local count: 536870913]:
_72 = 11;
<bb 10> [local count: 1073741817]:
# _73 = PHI <__i_68(7), _72(9)>
so we have
if (complicated way to tell the string is constant)
{
yay, compute it inline with a loop!
}
else
lenght = 11;
stupid. Very stupid.
More information about the Gcc-bugs
mailing list