Re: [PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

2021-06-18 Thread Jonathan Wakely via Gcc-patches
On Fri, 18 Jun 2021 at 18:44, Patrick Palka wrote: > > Ping; here's the same patch with the above comment corrected. > > -- >8 -- > > Subject: [PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison > complexity > > This rewrites ranges::minmax an

Re: [PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

2021-06-18 Thread Patrick Palka via Gcc-patches
; + // comparison, for a total of 3*(N-1)/2 + 1 < 3*N/2 > > > > comparisons. > > > > > > Same comments on the comments as above. > > > > Fixed. > > > > > > > > > + if (__comp_proj(*__prev, *__result.min)

Re: [PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

2021-05-05 Thread Patrick Palka via Gcc-patches
t; + if (__comp_proj(*__prev, *__result.min)) > > > + __result.min = __prev; > > > + if (!__comp_proj(*__first, *__result.max)) > > > + __result.max = __first; > > > + } > > > + else > > > +

Re: [PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

2021-05-05 Thread Patrick Palka via Gcc-patches
is an improvement though (except for > being slightly fewer lines of code): > > auto __mm = minmax(__prev, __first, __comp, >[](auto&& __it) -> auto&& { return *__it; }); > > if (__comp_proj(*__mm.min, *__result.min)) > _

Re: [PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

2021-05-05 Thread Jonathan Wakely via Gcc-patches
On 05/05/21 10:39 +0100, Jonathan Wakely wrote: On 04/05/21 21:42 -0400, Patrick Palka via Libstdc++ wrote: This rewrites ranges::minmax and ranges::minmax_element so that it performs at most 3*N/2 many comparisons, as required by the standard. In passing, this also fixes PR100387 by avoiding a

Re: [PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

2021-05-05 Thread Jonathan Wakely via Gcc-patches
On 04/05/21 21:42 -0400, Patrick Palka via Libstdc++ wrote: This rewrites ranges::minmax and ranges::minmax_element so that it performs at most 3*N/2 many comparisons, as required by the standard. In passing, this also fixes PR100387 by avoiding a premature std::move in ranges::minmax and in std:

[PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

2021-05-04 Thread Patrick Palka via Gcc-patches
This rewrites ranges::minmax and ranges::minmax_element so that it performs at most 3*N/2 many comparisons, as required by the standard. In passing, this also fixes PR100387 by avoiding a premature std::move in ranges::minmax and in std::shift_right. Tested on x86_64-pc-linux-gnu, does this look O