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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #7)
> Note to self/Patrick:
> 
> Measure whether it helps to specialize transform_view's iterator so that
> when _Base_iter is __normal_iterator we unwrap it and store a raw pointer.
> 
> Also, I suspect the indirections in
> 
>   return std::__invoke(*_M_parent->_M_fun, *_M_current);
> 
> are making the optimizer give up.
> 
> We have an indirection to the parent to access the semi-regular box, which
> has its own indirections. Maybe we could just get rid of the semi-regular
> box for a function pointer and store a function pointer (i.e. decay_t<Fp>)
> directly.
> 
> And maybe store a function pointer directly in the transform_view iterator,
> so we don't need to go to the parent to get it on every dereference.

Makes sense to me.  I think we could then get rid of the iterator's _M_parent
data member since it's used only to access the transformation function.  And
doing so would also reduce the size of the iterator in the case where the
transformation function is an empty functor (and so [[no_unique_address]] could
optimize away its storage).

> 
> Barry pointed out that range-v3 elides the use of semi-regular box for some
> cases, and he confirmed that storing a function pointer in the iterator
> helps.

FWIW we already elide the semiregular box for types which are semiregular, via
a partial specialization of __box that is just a [[no_unique_wrapper]] for the
underlying semiregular type.

Reply via email to