Use __restrict for __relocate_object_a
Marc Glisse
marc.glisse@inria.fr
Sat Apr 27 10:03:00 GMT 2019
Hello,
this small patch feels safe: we are moving an existing object to an
uninitialized location so the 2 locations can't overlap. And it helps with
std::vector<std::unique_ptr<int>> where it lets the compiler get rid of
the branches "if(...) delete ..." when moving elements around, for
instance in reserve(). We don't get a call to memmove yet (ldist may be
confused by clobbers, I'll investigate and report that later), but the
code gets much smaller at -O2, and we vectorize at -O3.
Similarly, I think the call to memmove in __relocate_a_1 could probably be
memcpy (I don't remember why I chose memmove), but that seems less
important and I don't want to mix it with this patch.
Bootstrap+regtest on x86_64-pc-linux-gnu.
2019-04-29 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/87106
* include/bits/stl_uninitialized.h (__relocate_object_a): Mark the
arguments with __restrict.
--
Marc Glisse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: restrict.patch
Type: text/x-diff
Size: 1228 bytes
Desc:
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190427/e353b8f9/attachment.bin>
More information about the Libstdc++
mailing list