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

Kangcheng Xu kxu at openjdk.org
Wed Apr 16 20:02:50 UTC 2025


On Fri, 11 Apr 2025 08:20:22 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> What I had in mind was something like that (I'm also fine with `CountedLoopConverter`:
>> 
>> CountedLoop counted_loop(...);
>> counted_loop.convert();
>> return counted_loop.is_valid();
>> 
>> But maybe you can explain in more detail what the follow-up work will be and how you use this class again later?
>
> About the placement of this class. You could probably also move it out of the already huge `PhaseIdealLoop` class to make it a non-inner class, if there is not some strong coupling that you absolutely need.

> [...] more detail what the follow-up work [...]

I was referring to [JDK-8336759](https://bugs.openjdk.org/browse/JDK-8336759) and #22449. Essentially I'm trying to achieve:

CountedLoopConverter c(...);
if (!c.is_counted_loop() && iv_bt == T_INT and && limit_t == T_LONG) {
    // transform `i < (long) limit` to `i < (int) (long) limit` if limit < INT_MAX
}

if (c.is_counted_loop()) {
    c.convert();
}


Which I personally think makes more sense to confirm a counted loops before trying out the conversion.

> [...] move it out of the already huge `PhaseIdealLoop` [...]

Yes, I agree! I found myself questioning this nested class, too.

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

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


More information about the hotspot-compiler-dev mailing list