[jdk18] RFR: 8278790: Inner loop of long loop nest runs for too few iterations
Roland Westrelin
roland at openjdk.java.net
Thu Dec 16 08:53:23 UTC 2021
Given a counted loop that iterates in [A, Z), when long range checks
are transformed into int range checks, a loop nest is created and
the inner loop iterates in [0, Z2).
The limits of the inner loop are adjusted to guarantee no overflow for
the range of values of the inner loop. That is for a range check:
i * scale + offset <u length
1) the bounds of the inner loop are adjusted to roughly [0,
max_jint/scale).
Also, we don't want to loose what we know about the bounds of the loop
being transformed.
2) So the bound of the inner loop are also adjusted to [0, min(Z2, Z - A))
The bug here is that 2) is performed before 1). This was spotted with
a micro benchmarks where the initial loop had only ~2000
iterations. The transformed loop is expected to run for the same 2000
iterations but instead ran for 2000/scale iterations.
-------------
Commit messages:
- fix
- alloc array fix
Changes: https://git.openjdk.java.net/jdk18/pull/35/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk18&pr=35&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8278790
Stats: 209 lines in 10 files changed: 130 ins; 57 del; 22 mod
Patch: https://git.openjdk.java.net/jdk18/pull/35.diff
Fetch: git fetch https://git.openjdk.java.net/jdk18 pull/35/head:pull/35
PR: https://git.openjdk.java.net/jdk18/pull/35
More information about the hotspot-compiler-dev
mailing list