RFR: 8291669: [REDO] Fix array range check hoisting for some scaled loop iv

Roland Westrelin roland at openjdk.org
Thu Aug 25 12:43:21 UTC 2022


On Thu, 25 Aug 2022 09:23:01 GMT, Pengfei Li <pli at openjdk.org> wrote:

>> src/hotspot/share/opto/loopTransform.cpp line 2773:
>> 
>>> 2771:       // AddX(iv*K1, iv*K2) => iv*(K1+K2)
>>> 2772:       jlong scale_sum = java_add(scale_l, scale_r);
>>> 2773:       if (scale_sum > max_signed_integer(exp_bt) || scale_sum < min_signed_integer(exp_bt)) {
>> 
>> That doesn't look good to me. This logic is shared between int and long counted loops. For a long counted loop, scale_l and scale_r are longs and testing for overflow that way doesn't work.
>
> My intention for this is to check INT overflow only. As this logic is shared by both INT and LONG, and we are using `java_add(jlong, jlong)` to add two INT scales, the addition result may only exceed the bounds of INT. For LONG scale values, it may overflow but that's fine because the result of `java_add()` wraps, so I don't think we need to check that for LONGs.

Ok. I think that's all right but the code needs a more detailed comment.

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

PR: https://git.openjdk.org/jdk/pull/9851


More information about the hotspot-compiler-dev mailing list