aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vectorizer.h
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-06-08 12:24:43 +0100
committerJonathan Wakely <jwakely@redhat.com>2023-06-09 13:08:25 +0100
commit960de5dd886572711ef86fa1e15e30d3810eccb9 (patch)
treee874baa0c91fa2050c592c137fc374a6db78fd61 /gcc/tree-vectorizer.h
parent3e12669a0eb968cfcbe9242b382fd8020935edf8 (diff)
downloadgcc-960de5dd886572711ef86fa1e15e30d3810eccb9.zip
gcc-960de5dd886572711ef86fa1e15e30d3810eccb9.tar.gz
gcc-960de5dd886572711ef86fa1e15e30d3810eccb9.tar.bz2
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.
Diffstat (limited to 'gcc/tree-vectorizer.h')
0 files changed, 0 insertions, 0 deletions