public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110167] excessive compile time for std::to_array with huge arrays Date: Tue, 12 Mar 2024 14:17:16 +0000 [thread overview] Message-ID: <bug-110167-4-Y2G9Xu0nvH@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110167-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110167 --- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:4c6bb36e88d5c8e510b10d12c01e3461c2aa4259 commit r13-8421-g4c6bb36e88d5c8e510b10d12c01e3461c2aa4259 Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Jun 8 12:24:43 2023 +0100 libstdc++: Optimize std::to_array for trivial types [PR110167] As reported in PR libstdc++/110167, std::to_array compiles extremely slowly for very large arrays. It needs to instantiate a very large specialization of std::index_sequence<N...> and then create a very large aggregate initializer from the pack expansion. For trivial types we can simply default-initialize the std::array and then use memcpy to copy the values. For non-trivial types we need to use the existing implementation, despite the compilation cost. As also noted in the PR, using a generic lambda instead of the __to_array helper compiles faster since gcc-13. It also produces slightly smaller code at -O1, due to additional inlining. The code at -Os, -O2 and -O3 seems to be the same. This new implementation requires __cpp_generic_lambdas >= 201707L (i.e. P0428R2) but that is supported since Clang 10 and since Intel icc 2021.5.0 (and since GCC 10.1). libstdc++-v3/ChangeLog: PR libstdc++/110167 * include/std/array (to_array): Initialize arrays of trivial types using memcpy. For non-trivial types, use lambda expressions instead of a separate helper function. (__to_array): Remove. * testsuite/23_containers/array/creation/110167.cc: New test. (cherry picked from commit 960de5dd886572711ef86fa1e15e30d3810eccb9)
next prev parent reply other threads:[~2024-03-12 14:17 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-08 3:18 [Bug libstdc++/110167] New: excessive compile time when optimizing std::to_array nightstrike at gmail dot com 2023-06-08 9:51 ` [Bug c++/110167] " redi at gcc dot gnu.org 2023-06-08 10:17 ` redi at gcc dot gnu.org 2023-06-08 10:21 ` redi at gcc dot gnu.org 2023-06-08 10:22 ` redi at gcc dot gnu.org 2023-06-08 11:05 ` redi at gcc dot gnu.org 2023-06-08 15:01 ` redi at gcc dot gnu.org 2023-06-08 15:09 ` redi at gcc dot gnu.org 2023-06-08 15:28 ` [Bug libstdc++/110167] " redi at gcc dot gnu.org 2023-06-08 15:30 ` [Bug libstdc++/110167] excessive compile time for std::to_array with huge arrays redi at gcc dot gnu.org 2023-06-08 15:44 ` redi at gcc dot gnu.org 2023-06-09 7:00 ` rguenth at gcc dot gnu.org 2023-06-09 12:08 ` cvs-commit at gcc dot gnu.org 2023-10-19 14:07 ` redi at gcc dot gnu.org 2024-03-12 14:17 ` cvs-commit at gcc dot gnu.org [this message] 2024-03-13 9:52 ` cvs-commit at gcc dot gnu.org 2024-03-13 10:00 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-110167-4-Y2G9Xu0nvH@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).