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

Kangcheng Xu kxu at openjdk.org
Mon Nov 3 19:25:10 UTC 2025


> 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 38 commits:

 - fix bad merge
 - Merge remote-tracking branch 'origin/master' into counted-loop-refactor
   
   # Conflicts:
   #	src/hotspot/share/opto/loopnode.cpp
 - follow-up review 3383037106
 - Update src/hotspot/share/opto/loopnode.hpp
   
   Co-authored-by: Christian Hagedorn <christian.hagedorn at oracle.com>
 - mark LoopExitTest::is_valid_with_bt() const
 - fix iv increment basic type and truncated increment check
 - add safepoint opcode condition
 - follow-up review 3321712957
 - 8354383: C2: enable sinking of Type nodes out of loop
   
   Reviewed-by: chagedorn, thartmann
   (cherry picked from commit a2f99fd88bd03337e1ba73b413ffe4e39f3584cf)
 - Merge remote-tracking branch 'origin/master' into counted-loop-refactor
   
   # Conflicts:
   #	src/hotspot/share/opto/loopnode.cpp
 - ... and 28 more: https://git.openjdk.org/jdk/compare/9f972008...de71e7c8

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

Changes: https://git.openjdk.org/jdk/pull/24458/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24458&range=19
  Stats: 1197 lines in 3 files changed: 606 ins; 283 del; 308 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