RFR: 8353290: C2: Refactor PhaseIdealLoop::is_counted_loop()

Kangcheng Xu kxu at openjdk.org
Wed Apr 9 15:52:55 UTC 2025


This PR refactors `PhaseIdealLoop::is_counted_loop()` into (mostly) `CountedLoopConverter::is_counted_loop()` and `CountedLoopConverter::convert()` to decouple to detection and conversion code. This enables us to try different loop configurations easy 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).

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

Commit messages:
 - line break
 - remove TODOs
 - Revert "improve formatting, naming, comments"
 - improve formatting, naming, comments
 - Merge branch 'master' into counted-loop-refactor
 - improve formatting, naming, comments
 - rearrange code for a more sensible diff
 - clean up code
 - extract stress_long_counted_loop()
 - remove debug lines
 - ... and 5 more: https://git.openjdk.org/jdk/compare/9a391f44...3db745d2

Changes: https://git.openjdk.org/jdk/pull/24458/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24458&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8353290
  Stats: 544 lines in 3 files changed: 179 ins; 86 del; 279 mod
  Patch: https://git.openjdk.org/jdk/pull/24458.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24458/head:pull/24458

PR: https://git.openjdk.org/jdk/pull/24458


More information about the hotspot-compiler-dev mailing list