Re: [PATCH v1] libstdc++: More efficient weekday from year_month_day.

2025-05-13 Thread Cassio Neri
Adding link for xref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120264 Thanks, Cassio. On Mon, 12 May 2025 at 10:06, Jonathan Wakely wrote: > On Sun, 11 May 2025 at 12:34, Cassio Neri wrote: > > > > Hi all, > > > > After reflecting on my previous message and Andrew's, I now believe this > pa

Re: [PATCH v1] libstdc++: More efficient weekday from year_month_day.

2025-05-12 Thread Jonathan Wakely
On Sun, 11 May 2025 at 12:34, Cassio Neri wrote: > > Hi all, > > After reflecting on my previous message and Andrew's, I now believe this > patch is not the best solution to optimise the day of the week. Instead, the > optimisation for n % 7 should be done by the compiler depending on the > pla

Re: [PATCH v1] libstdc++: More efficient weekday from year_month_day.

2025-05-11 Thread Cassio Neri
Hi all, After reflecting on my previous message and Andrew's, I now believe this patch is not the best solution to optimise the day of the week. Instead, the optimisation for n % 7 should be done by the compiler depending on the platform. I'll open a missing optimisation opportunity bug report ag

Re: [PATCH v1] libstdc++: More efficient weekday from year_month_day.

2025-05-10 Thread Cassio Neri
Thanks Andrew for your prompt reply. The results below regard my PoC which is as close to the proposed patch as I could make. This is because I can't have chrono with my patch on godbold for a comparison between current chrono and patched chrono. I tried on all platforms that I could make it to c

Re: [PATCH v1] libstdc++: More efficient weekday from year_month_day.

2025-05-10 Thread Andrew Pinski
On Mon, May 5, 2025, 11:48 AM Cassio Neri wrote: > Use a better algorithm to calculate n % 7, taking into account that the > divisor > is a Mersenne number. This is explained in this two-part lightning talk at > CppCon 2024 [1, 2]. > > Roughly speaking, the algorithm is used for n = sys_days but

[PATCH v1] libstdc++: More efficient weekday from year_month_day.

2025-05-05 Thread Cassio Neri
Use a better algorithm to calculate n % 7, taking into account that the divisor is a Mersenne number. This is explained in this two-part lightning talk at CppCon 2024 [1, 2]. Roughly speaking, the algorithm is used for n = sys_days but it has a precondition that doesn't hold for all values of sys_