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

Christian Hagedorn chagedorn at openjdk.org
Fri Apr 11 08:24:26 UTC 2025


On Thu, 10 Apr 2025 15:30:24 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 incrementally with one additional commit since the last revision:
> 
>   reviewer suggested changes

src/hotspot/share/opto/loopnode.cpp line 1627:

> 1625: }
> 1626: 
> 1627: bool PhaseIdealLoop::CountedLoopConverter::is_counted_loop() {

`is_counted_loop()` is still huge. When trying to refactor it anyway, it might be a good idea to further split the code up into separate methods for all the different checks. That would increase the readability since we have a lot of different checks.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24458#discussion_r2039046541


More information about the hotspot-compiler-dev mailing list