[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2024-12-14 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #16 from Jan Hubicka --- https://gcc.gnu.org/pipermail/gcc-patches/2024-December/671599.html optimizes the string constructors. Having strlen pass catching more cases would be nice, too.

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2024-12-09 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #15 from Jakub Jelinek --- Note, while strlen pass has laststmt and some handling of it for the other direction, shrinking of the memcpy etc. size if the nul byte is being immediately overwritten, it is actually tree DSE which optimiz

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2024-12-09 Thread hubicka at ucw dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #14 from Jan Hubicka --- > > So I think all we can hope for is merging memcpy with the extra write of 0. > > That's not actually clear. > > It would be reasonable to assume that foo isn't likely to change the string > and have the i

Re: [Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2024-12-09 Thread Jan Hubicka via Gcc-bugs
> > So I think all we can hope for is merging memcpy with the extra write of 0. > > That's not actually clear. > > It would be reasonable to assume that foo isn't likely to change the string > and have the inlined destructor for a string that was initialized as a short > string like here do somet

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2024-12-08 Thread terra at gnome dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #13 from M Welinder --- > The reason why full destructor is inlined is that we do not know what > foo is doing and it may make the string bigger. "const" does not promise > that the callee does not modify the object. :-( > So I th

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2024-12-08 Thread hubicka at ucw dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #12 from Jan Hubicka --- > (In reply to Jakub Jelinek from comment #10) > > __builtin_memcpy (&D.35539.D.25336._M_local_buf, "abc", 3); > > MEM[(char_type &)&D.35539 + 11] = 0; > > change to > > __builtin_memcpy (&D.35539.D.2533

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2024-12-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 Andrew Pinski changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2024-12-08 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #10 from Jakub Jelinek --- __builtin_memcpy (&D.35539.D.25336._M_local_buf, "abc", 3); MEM[(char_type &)&D.35539 + 11] = 0; change to __builtin_memcpy (&D.35539.D.25336._M_local_buf, "abc", 4); seems like something that the strl

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2024-12-08 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 Jan Hubicka changed: What|Removed |Added CC||hubicka at gcc dot gnu.org Ever confir

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2021-12-25 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #8 from Andrew Pinski --- (In reply to Marc Glisse from comment #3) > (In reply to M Welinder from comment #2) > > The destruction still stinks: the full destructor is inlined instead of > > the small-string-only version (i.e., a no-o

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2018-10-05 Thread terra at gnome dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #7 from M Welinder --- Actually, it's more like 50+ instructions for destructing the string that never (or almost never) needs destructing. 16 of those appear to need linker fixup. Sample for the C++14 mode: callZ3fo

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2018-10-05 Thread terra at gnome dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #6 from M Welinder --- > const_cast(s)="some longer string so it needs proper deletion"; Is that really valid? This comes down to whether the temporary object creating with the function call is constant [in which case the above is U

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2018-10-05 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #5 from Andrew Pinski --- The C++17 calling a function part of this issue is record as PR 86590 already. The rest is a different issue and should be looked into.

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2018-10-05 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 Martin Liška changed: What|Removed |Added CC||redi at gcc dot gnu.org --- Comment #4 fr

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2018-10-04 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #3 from Marc Glisse --- (In reply to M Welinder from comment #2) > The destruction still stinks: the full destructor is inlined instead of > the small-string-only version (i.e., a no-op). Evidently gcc cannot > see that the string re

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2018-10-04 Thread terra at gnome dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 --- Comment #2 from M Welinder --- Created attachment 44789 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44789&action=edit Proof-on-concept patch This proof-of-concept improves the situation dramatically. I don't know if it is actually

[Bug libstdc++/87502] Poor code generation for std::string("c-style string")

2018-10-04 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502 Martin Liška changed: What|Removed |Added CC||jakub at gcc dot gnu.org,