RFR: 8342692: C2: long counted loop/long range checks: don't create loop-nest for short running loops [v32]
Roland Westrelin
roland at openjdk.org
Tue May 27 15:34:22 UTC 2025
On Tue, 27 May 2025 07:33:05 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Roland Westrelin has updated the pull request incrementally with one additional commit since the last revision:
>>
>> review
>
> src/hotspot/share/opto/loopnode.cpp line 1278:
>
>> 1276: #endif
>> 1277: entry_control = head->skip_strip_mined()->in(LoopNode::EntryControl);
>> 1278: } else if (bt == T_LONG) {
>
> Suggestion:
>
> } else if (bt == T_LONG) {
> assert(known_short_running_loop, "follows from earlier bailout check.");
>
> I suppose that is what you mean by `won't need loop limit checks (iters_limit guarantees that)`, right?
The `LongCountedLoop` is turned into a `Loop` here which, on a following pass of loop opts, is turned into a `CountedLoop`. That `CountedLoop` doesn't need loop limit check predicates because of the way its bounds are constructed. But, sometimes, by the time the `CountedLoop` is created, some transformation happened to the bounds and the code that creates the `CountedLoop` can't tell the loop limit checks are not needed. The `Cast` is added to make sure the `CountedLoop` logic sees the bounds are such that the loop limit checks should not be added.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21630#discussion_r2109517371
More information about the hotspot-compiler-dev
mailing list