aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorCassio Neri <cassio.neri@gmail.com>2023-11-11 22:59:50 +0000
committerJonathan Wakely <jwakely@redhat.com>2023-11-14 22:32:08 +0000
commit86a0df1a6c7fe4a835620b868e76ea78d42d6620 (patch)
treeaa03c7925bbe6429e24ed974d5b6e949ef3c4d1e /libcpp
parentb011535456396a6846ff24fb5b1baea8fe0a33b1 (diff)
downloadgcc-86a0df1a6c7fe4a835620b868e76ea78d42d6620.zip
gcc-86a0df1a6c7fe4a835620b868e76ea78d42d6620.tar.gz
gcc-86a0df1a6c7fe4a835620b868e76ea78d42d6620.tar.bz2
libstdc++: Simplify year::is_leap()
The current implementation returns (_M_y & (__is_multiple_of_100 ? 15 : 3)) == 0; where __is_multiple_of_100 is calculated using an obfuscated algorithm which saves one ror instruction when compared to _M_y % 100 == 0 [1]. In leap years calculation, it's correct to replace the divisibility check by 100 with the one by 25. It turns out that _M_y % 25 == 0 also saves the ror instruction [2]. Therefore, the obfuscation is not required. [1] https://godbolt.org/z/5PaEv6a6b [2] https://godbolt.org/z/55G8rn77e libstdc++-v3/ChangeLog: * include/std/chrono (year::is_leap): Clear code.
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions