public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: More efficient std::chrono::year::leap.
@ 2021-05-21 17:46 Cassio Neri
  2021-05-21 18:05 ` Koning, Paul
  0 siblings, 1 reply; 8+ messages in thread
From: Cassio Neri @ 2021-05-21 17:46 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Simple change to std::chrono::year::is_leap. If a year is multiple of 100,
then it's divisible by 400 if and only if it's divisible by 16. The latter
allows for better code generation.

Tested on x86_64-pc-linux-gnu.

libstdc++-v3/ChangeLog:

* include/std/chrono:

diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index 4631a727d73..6221d02c1b3 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -1612,7 +1612,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  constexpr uint32_t __offset       = __max_dividend / 2 / 100 * 100;
  const bool __is_multiple_of_100
   = __multiplier * (_M_y + __offset) < __bound;
- return (!__is_multiple_of_100 || _M_y % 400 == 0) && _M_y % 4 == 0;
+ return (!__is_multiple_of_100 || _M_y % 16 == 0) && _M_y % 4 == 0;
       }

       explicit constexpr

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-24 11:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 17:46 [PATCH] libstdc++: More efficient std::chrono::year::leap Cassio Neri
2021-05-21 18:05 ` Koning, Paul
2021-05-21 18:44   ` Cassio Neri
2021-06-23 11:45     ` Jonathan Wakely
2021-06-23 13:16       ` Jonathan Wakely
2021-06-23 17:51         ` Jonathan Wakely
2021-06-23 17:52           ` Jonathan Wakely
2021-06-24 11:42             ` Cassio Neri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).