A few integer divisions and multiplications can be replaced with test + addition, leading to a decent speed-up on java.time microbenchmarks such as `GetYearBench`. Numbers from my local x86 workstation, seeing similar speed-up on aarch64 and other x86 setups.
Baseline: Benchmark Mode Cnt Score Error Units GetYearBench.getYearFromMillisZoneOffset thrpt 15 18.492 ± 0.017 ops/ms GetYearBench.getYearFromMillisZoneRegion thrpt 15 6.121 ± 0.135 ops/ms GetYearBench.getYearFromMillisZoneRegionNormalized thrpt 15 18.936 ± 0.012 ops/ms GetYearBench.getYearFromMillisZoneRegionUTC thrpt 15 9.283 ± 0.222 ops/ms Patched: Benchmark Mode Cnt Score Error Units GetYearBench.getYearFromMillisZoneOffset thrpt 15 20.931 ± 0.013 ops/ms GetYearBench.getYearFromMillisZoneRegion thrpt 15 6.858 ± 0.167 ops/ms GetYearBench.getYearFromMillisZoneRegionNormalized thrpt 15 20.923 ± 0.017 ops/ms GetYearBench.getYearFromMillisZoneRegionUTC thrpt 15 10.028 ± 0.182 ops/ms Testing: java.time tests locally, CI tier1+2 ongoing. ------------- Commit messages: - Reduce cost of year and month calculations Changes: https://git.openjdk.java.net/jdk/pull/8039/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8039&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8283996 Stats: 12 lines in 2 files changed: 6 ins; 1 del; 5 mod Patch: https://git.openjdk.java.net/jdk/pull/8039.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8039/head:pull/8039 PR: https://git.openjdk.java.net/jdk/pull/8039