RFR: 8319423: Improve Year.isLeap by checking divisibility by 16

Claes Redestad redestad at openjdk.org
Thu Nov 9 12:00:15 UTC 2023


On Wed, 8 Nov 2023 16:51:48 GMT, Lothar Kimmeringer <job at kimmeringer.de> wrote:

> return (year & 3) == 0 && (year & 15 == 0 || year % 100 != 0);

I tried this and many other variants but the one in this PR came out on top - and it even seemed the additional redundancy helped the JIT. This might be due a deficiency in how C2 handles conditional moves, so I stuck to the one that generated the seemingly best code layout with a plan to re-evaluate (and hopefully simplify) this once https://bugs.openjdk.org/browse/JDK-8319451 is resolved. There's already a PR out #16524 so hopefully we can re-visit this soon.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/16491#issuecomment-1803695864


More information about the core-libs-dev mailing list