RFR: 8342692: C2: long counted loop/long range checks: don't create loop-nest for short running loops [v20]

Roland Westrelin roland at openjdk.org
Thu May 15 15:31:01 UTC 2025


On Thu, 15 May 2025 12:23:26 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> Roland Westrelin has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Emanuel's review
>>  - Christian's review
>
> src/hotspot/share/opto/loopnode.cpp line 1198:
> 
>> 1196:       profile_short_running_loop = true;
>> 1197:     } else {
>> 1198:       profile_short_running_loop = !head->is_profile_trip_failed() && head->profile_trip_cnt() < iters_limit / ABS(stride_con);
> 
> Why do we compare with `<=` above but here with `<`?

Right. No reason it's not the same.

> src/hotspot/share/opto/loopnode.cpp line 1225:
> 
>> 1223:     // Predicate). The current limit could, itself, be dependent on an existing predicate. Clone parse and template
>> 1224:     // assertion predicates below existing predicates to get proper ordering of predicates when walking from the loop
>> 1225:     // up: future predicates, Short Running Long Loop Predicate, existing predicates.
> 
> Maybe you missed the visualization I've added in a comment for an earlier commit. I would find it quite useful to quickly grasp the idea, what do you think?
> 
> 
> //
> //        Existing Hoisted 
> //        Check Predicates  
> //              |         
> //     New Short Running Long        
> //         Loop Predicate
> //              |
> //   Cloned Parse Predicates and 
> //  Template Assertion Predicates        
> //              |
> //             Loop

I must have missed it. Sorry about that.

> src/hotspot/share/opto/loopnode.cpp line 1269:
> 
>> 1267:     }
>> 1268: #endif
>> 1269:     entry_control = head->skip_strip_mined()->in(LoopNode::EntryControl);
> 
> It looks like this line rather belongs to the `Predicate` on L1275? Might have been moved here by accident.

I don't think that's the case. Predicates were added so `entry_control` needs to be refreshed.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21630#discussion_r2091458756
PR Review Comment: https://git.openjdk.org/jdk/pull/21630#discussion_r2091452769
PR Review Comment: https://git.openjdk.org/jdk/pull/21630#discussion_r2091455479


More information about the hotspot-compiler-dev mailing list