[Bug libstdc++/51965] Redundant move constructions in heap algorithms
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 19 23:11:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51965
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2012-01-24 00:00:00 |2017-1-19
Target Milestone|--- |8.0
--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #5)
> (The split into push_heap and __push_heap is just so the first part can be
> inlined without the second, right?)
>
> A more direct adaptation of the old code to rvalue references would be:
>
> std::__push_heap(__first, _DistanceType((__last - __first) - 1),
> _DistanceType(0), _ValueType(_GLIBCXX_MOVE(*(__last -
> 1))));
I tried doing this and it didn't seem to help the testcase attached here.
> Without the named temporary value, the compiler can perform copy elision.
> Aliaksandr's patch looks like a different way to achieve the same goal.
The patch doesn't apply cleanly, but I made the equivalent changes to the
latest code and found some regressions, so I'll revisit it for gcc 8.
> Note that the current code thus seems to have a performance regression in
> C++03 compared to before the introduction of moves.
Yes.
More information about the Gcc-bugs
mailing list