RFR: 8342692: C2: long counted loop/long range checks: don't create loop-nest for short running loops [v20]
Christian Hagedorn
chagedorn at openjdk.org
Wed May 21 08:40:09 UTC 2025
On Thu, 15 May 2025 15:31:57 GMT, Roland Westrelin <roland at openjdk.org> wrote:
>> src/hotspot/share/opto/loopnode.cpp line 1172:
>>
>>> 1170: // Only process if we are in the correct Predicate Block.
>>> 1171: return;
>>> 1172: }
>>
>> Do we really need this check? Could we not just clone all Template Assertion Predicates that we find? I think with the recent Assertion Predicate changes, we are sure that all Template Assertion Predicates found belong to this loop. Otherwise, they would already be marked useless and `visit()` is not called on them.
>
> Well, I trust you on that. Things have changed quite a bit recently with Assertion Predicates and it's hard to keep up!
That's true, a lot has changed. But I think it should be safe. Are you planning to integrate this in JDK 25 or could it also go into JDK 26? In the latter case, we have some more baking time.
>> src/hotspot/share/opto/loopnode.cpp line 1191:
>>
>>> 1189: loop->compute_trip_count(this, bt);
>>> 1190: // Loop must run for no more than iter_limits as it guarantees no overflow of scale * iv in long range checks.
>>> 1191: bool known_short_running_loop = head->trip_count() <= iters_limit / ABS(stride_con);
>>
>> Can you also add a comment about the decision of the hardcoded `iters_limit / ABS(stride_con)` limit to indicate a short running long loop?
>
> Rather than `ShortLoopIter`? Or is it something else that you'd like to be better explained?
Yes, rather than `ShortLoopIter`. One could think that it could be a good idea to have such a flag.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21630#discussion_r2099701484
PR Review Comment: https://git.openjdk.org/jdk/pull/21630#discussion_r2099704551
More information about the hotspot-compiler-dev
mailing list