RFR: 8353290: C2: Refactor PhaseIdealLoop::is_counted_loop() [v28]

Christian Hagedorn chagedorn at openjdk.org
Thu Jan 8 13:00:49 UTC 2026


On Wed, 7 Jan 2026 17:08:57 GMT, Kangcheng Xu <kxu at openjdk.org> wrote:

>> This PR refactors `PhaseIdealLoop::is_counted_loop()` into (mostly) `CountedLoopConverter::is_counted_loop()` and `CountedLoopConverter::convert()` to decouple the detection and conversion code. This enables us to try different loop configurations easily and finally convert once a counted loop is found. 
>> 
>> A nested `PhaseIdealLoop::CountedLoopConverter` class is created to handle the context, but I'm not if this is the best name or place for it. Please let me know what you think.
>> 
>> Blocks [JDK-8336759](https://bugs.openjdk.org/browse/JDK-8336759).
>
> Kangcheng Xu has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 50 commits:
> 
>  - Merge remote-tracking branch 'origin/master' into counted-loop-refactor
>  - Update license header years
>  - Merge remote-tracking branch 'origin/master' into counted-loop-refactor
>  - remove trailing whitespaces
>  - Merge remote-tracking branch 'origin/master' into counted-loop-refactor
>  - additional suggestions from code review
>  - Apply suggestions from code review
>    
>    Co-authored-by: Christian Hagedorn <christian.hagedorn at oracle.com>
>  - fix trip counter loop-variant detection
>  - fix bad merge with ctrl_is_member()
>  - Merge remote-tracking branch 'origin/master' into counted-loop-refactor
>    
>    # Conflicts:
>    #	src/hotspot/share/opto/loopnode.cpp
>  - ... and 40 more: https://git.openjdk.org/jdk/compare/640343f7...7783d609

The last update looks good, thanks for addressing all my comments! I've submitted some testing up to tier4 with this patch and your prepared [counted-loop-refactor-old-vs-new](https://github.com/tabjy/jdk/commits/counted-loop-refactor-old-vs-new/) branch. Thanks a lot for doing that! I will report back once I got the results. If they look good, I also run this through some higher tiers over the weekend.

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

PR Comment: https://git.openjdk.org/jdk/pull/24458#issuecomment-3723761609


More information about the hotspot-compiler-dev mailing list