[jdk18] RFR: 8278790: Inner loop of long loop nest runs for too few iterations [v2]

Nils Eliasson neliasso at openjdk.java.net
Thu Dec 16 09:41:55 UTC 2021


On Thu, 16 Dec 2021 09:13:40 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> 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.
>
> Roland Westrelin has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR.

Looks good!

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

Marked as reviewed by neliasso (Reviewer).

PR: https://git.openjdk.java.net/jdk18/pull/35


More information about the hotspot-compiler-dev mailing list