RFR: 8353290: C2: Refactor PhaseIdealLoop::is_counted_loop() [v3]
Kangcheng Xu
kxu at openjdk.org
Mon Nov 10 16:33:12 UTC 2025
On Thu, 23 Oct 2025 08:02:47 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> @chhagedorn Sorry this took longer than expected. I left a few replies under some of your specific comments. All other issues were addressed. Thank you!
>
> No worries, thanks @tabjy for addressing my suggestions and comments! I won't be able to continue this week but will have another look next week.
> @chhagedorn: Have you thought about some ways to test this? One idea could be to do some runs with some custom logging in place when a counted loop was successfully created and then compare the output to a baseline without your patch and the same logging in place.
That's a very good suggestion. I tried logging the method id where a counted loop is detected and converted and run `tier2_ctw` with it. However, the the results are not stable between multiple runs (everytime I get a more or less counted loops detected, even with the old code). There was some non-determinism either in the HS or the JCL code. I couldn't identify them.
Alternatively, I cherry-picked the old counted loop implementation back in with minimum changes and asserted the old and new implementation always produce the same result. This is done on another branch [0] to avoid complicating reviews. All of the `tier1` tests pass on GHA [0] and `tier2_ctw` pass locally as well (I pinkly swear!).
https://github.com/tabjy/jdk/blob/8c1a8c02574af9e2a7b073fc729b3474f187d361/src/hotspot/share/opto/loopnode.cpp#L3010-L3016
So yes, I'm quite confident there's no regressions.
[0] https://github.com/tabjy/jdk/compare/counted-loop-refactor...tabjy:jdk:counted-loop-refactor-log
[1] https://github.com/tabjy/jdk/actions/runs/19149109113
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24458#issuecomment-3512700057
More information about the hotspot-compiler-dev
mailing list