public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/110793] New: regression in optimizing unused string @ 2023-07-24 14:17 barry.revzin at gmail dot com 2023-07-24 14:36 ` [Bug c++/110793] " redi at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: barry.revzin at gmail dot com @ 2023-07-24 14:17 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110793 Bug ID: 110793 Summary: regression in optimizing unused string Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Consider this reduced, silly-looking example: #include <string> inline int zero(std::string const& = {}) { return 0; } int main() { return zero(); } In several versions of gcc (12.2, 11.4, 10.5), this simply compiles to: main: xor eax, eax ret But in 13.1 (C++17, but not C++20), we get: main: sub rsp, 40 lea rax, [rsp+16] mov rdi, rsp mov BYTE PTR [rsp+16], 0 mov QWORD PTR [rsp], rax mov QWORD PTR [rsp+8], 0 call std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose() xor eax, eax add rsp, 40 ret Notably, 13.1 C++20 and C++23 also compiles to just xor. I'm not sure if this is a language or library issue, so tagging it language for now. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/110793] regression in optimizing unused string 2023-07-24 14:17 [Bug c++/110793] New: regression in optimizing unused string barry.revzin at gmail dot com @ 2023-07-24 14:36 ` redi at gcc dot gnu.org 2023-07-24 14:48 ` [Bug ipa/110793] " pinskia at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2023-07-24 14:36 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110793 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Barry Revzin from comment #0) > Notably, 13.1 C++20 and C++23 also compiles to just xor. > Probably because we don't use the extern template declarations for C++20. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/110793] regression in optimizing unused string 2023-07-24 14:17 [Bug c++/110793] New: regression in optimizing unused string barry.revzin at gmail dot com 2023-07-24 14:36 ` [Bug c++/110793] " redi at gcc dot gnu.org @ 2023-07-24 14:48 ` pinskia at gcc dot gnu.org 2023-07-24 15:04 ` pinskia at gcc dot gnu.org 2023-07-24 15:04 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-07-24 14:48 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110793 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marxin at gcc dot gnu.org Component|c++ |ipa --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Actually this is more likely inlining heuristics that know that main is only called once ever and does not inline as much into it. Try renaming main to foo and try again b ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/110793] regression in optimizing unused string 2023-07-24 14:17 [Bug c++/110793] New: regression in optimizing unused string barry.revzin at gmail dot com 2023-07-24 14:36 ` [Bug c++/110793] " redi at gcc dot gnu.org 2023-07-24 14:48 ` [Bug ipa/110793] " pinskia at gcc dot gnu.org @ 2023-07-24 15:04 ` pinskia at gcc dot gnu.org 2023-07-24 15:04 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-07-24 15:04 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110793 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #2) > Actually this is more likely inlining heuristics that know that main is only > called once ever and does not inline as much into it. > > Try renaming main to foo and try again b Yes it is this heurstic. Renaming main to foo produces: foo(): .LFB1395: .cfi_startproc xorl %eax, %eax ret For all optimization levels. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/110793] regression in optimizing unused string 2023-07-24 14:17 [Bug c++/110793] New: regression in optimizing unused string barry.revzin at gmail dot com ` (2 preceding siblings ...) 2023-07-24 15:04 ` pinskia at gcc dot gnu.org @ 2023-07-24 15:04 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-07-24 15:04 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110793 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #3) > For all optimization levels. I mean for all C++ standards. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-24 15:04 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-07-24 14:17 [Bug c++/110793] New: regression in optimizing unused string barry.revzin at gmail dot com 2023-07-24 14:36 ` [Bug c++/110793] " redi at gcc dot gnu.org 2023-07-24 14:48 ` [Bug ipa/110793] " pinskia at gcc dot gnu.org 2023-07-24 15:04 ` pinskia at gcc dot gnu.org 2023-07-24 15:04 ` 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).