diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-06-19 16:14:56 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2024-06-21 17:06:59 +0100 |
commit | b3743181899c5490a94c4dbde56a69ab77a40f11 (patch) | |
tree | 5cc7630c6d16153b5564862a6656ebc3656798ff /gcc | |
parent | 77f321435b4ac37992c2ed6737ca0caa1dd50551 (diff) | |
download | gcc-b3743181899c5490a94c4dbde56a69ab77a40f11.zip gcc-b3743181899c5490a94c4dbde56a69ab77a40f11.tar.gz gcc-b3743181899c5490a94c4dbde56a69ab77a40f11.tar.bz2 |
libstdc++: Fix std::fill and std::fill_n optimizations [PR109150]
As noted in the PR, the optimization used for scalar types in std::fill
and std::fill_n is non-conforming, because it doesn't consider that
assigning a scalar type might have non-trivial side effects which are
affected by the optimization.
By changing the condition under which the optimization is done we ensure
it's only performed when safe to do so, and we also enable it for
additional types, which was the original subject of the PR.
Instead of two overloads using __enable_if<__is_scalar<T>::__value, R>
we can combine them into one and create a local variable which is either
a local copy of __value or another reference to it, depending on whether
the optimization is allowed.
This removes a use of std::__is_scalar, which is a step towards fixing
PR 115497 by removing std::__is_pointer from <bits/cpp_type_traits.h>
libstdc++-v3/ChangeLog:
PR libstdc++/109150
* include/bits/stl_algobase.h (__fill_a1): Combine the
!__is_scalar and __is_scalar overloads into one and rewrite the
condition used to decide whether to perform the load outside the
loop.
* testsuite/25_algorithms/fill/109150.cc: New test.
* testsuite/25_algorithms/fill_n/109150.cc: New test.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions