[Bug libstdc++/51965] Redundant move constructions in heap algorithms

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Mar 29 19:20:58 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51965

--- Comment #19 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #16)
> (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.

push_heap(): default_ctors=0, copy_ctors=0, copy_assignments=0, swaps=0,
[-cheap_dtors=1998,-] {+cheap_dtors=999,+} expensive_dtors=0,
[-move_ctors=1998,-] {+move_ctors=999,+} cheap_move_assignments=2201,
expensive_move_assignments=0, comparisons=2196

It doesn't help the other operations, but it has some effect on this one.


More information about the Gcc-bugs mailing list