RFR: 8261308: C2: assert(inner->is_valid_counted_loop(T_INT) && inner->is_strip_mined()) failed: OuterStripMinedLoop should have been removed
Vladimir Kozlov
kvn at openjdk.java.net
Wed Feb 24 19:35:47 UTC 2021
On Wed, 24 Feb 2021 14:57:15 GMT, Roland Westrelin <roland at openjdk.org> wrote:
>> src/hotspot/share/opto/loopTransform.cpp line 126:
>>
>>> 124: jlong limit_con = (stride_con > 0) ? limit_type->_hi : limit_type->_lo;
>>> 125: int stride_m = stride_con - (stride_con > 0 ? 1 : -1);
>>> 126: jlong trip_count = (limit_con - init_con + stride_m)/stride_con;
>>
>> Does it mean that before we execute do_one_iteration_loop() optimization for loops which do 2 trips?
>> This seems wrong. Can you check?
>> I agree that loop body executed at least once since it is exit check. But it means we have to generally adjust `trip_count` with `+1` and not do what you suggested.
>
> Thanks for the comments.
> A CountedLoopNode/CountedLoopEndNode is this in pseudo code:
> int i = init;
> do {
> i += stride;
> } while (i < limit);
> for stride > 0
> We always enter the loop body so execute it at least once.
> If limit > init, it's executed: (limit - init) / stride times if (limit - init) is a multiple of stride.
> if (limit - init) is not a multiple of stride then it's executed (limit - init) / stride + 1.
> That matches the formula in the source code AFAICT.
> In what case do you think we compute 1 for the trip count when it's actually 2?
> How would you compute the trip count?
I looked on history and before your 8256655 changes we did not create counted loop for such case:
https://github.com/openjdk/jdk/blob/f504f419d3b377f0ccfd458026a2b57a9704bdff/src/hotspot/share/opto/loopnode.cpp#L1376
That is why we did not hit this issue before. After 8256655 we allow counted loops with `init >= limit`. Got it.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2529
More information about the hotspot-compiler-dev
mailing list