[lworld] RFR: 8337747: [lworld] Refactor Loop Unswitching code after merging in JDK-8325746

Christian Hagedorn chagedorn at openjdk.org
Tue Aug 6 11:14:20 UTC 2024


In the merge of JDK-8325746 for tag jdk-23+12, I've applied just a minimal refactoring to get things to work with as few changes as possible in Valhalla and decided to make a full refactoring separately with this patch.

This patch includes the following:
- Improved/updated comments
- New `UnswitchCandidate` class:
  - Since we can have multiple unswitch candidates with flat array checks, I've introduced a new class `UnswitchCandidate` which finds either a unique candidate or a list of flat array checks which can also be queried from this class.
  - Offers methods `update_in_false/true_path_loop()` methods to remove the dominated unswitch candidates (previously in `OriginalLoop::remove_unswitch_candidate_from_loops()`
  - Offers method `merge_flat_array_checks()` to create a merged flat array check bool (previously in `UnswitchedLoopSelector::find_unswitch_candidate()`)
- Updated `UnswitchedLoopSelector` class:
  - Now only responsible for creating the loop unswitching loop selector and not for finding the unswitch candidate - this is passed into the class now.   
- Clean up `PhaseIdealLoop::find_unswitch_candidates()`
- Clean up printing for `TraceLoopOpts` and `TraceLoopUnswitching`. Now the details are only guarded with `TraceLoopUnswitching` to reduce the noise with `TraceLoopOpts`. Example output with `TraceLoopUnswitching`:

Loop Unswitching:
- Unswitch-Candidate-If: 519 If
- Loop-Selector-If: 2094 If
- True-Path-Loop (=Orig): 1346 Loop
- False-Path-Loop (=Clone): 2221 Loop
- Unswitched Flat Array Checks:
  - 519 If  ->  2226 If
  - 922 If  ->  2208 If
  - 685 If  ->  2359 If
  - 580 If  ->  2388 If


Thanks,
Christian

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

Commit messages:
 - 8337747: [lworld] Refactor Loop Unswitching code after merging in JDK-8325746

Changes: https://git.openjdk.org/valhalla/pull/1194/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1194&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8337747
  Stats: 336 lines in 2 files changed: 196 ins; 99 del; 41 mod
  Patch: https://git.openjdk.org/valhalla/pull/1194.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1194/head:pull/1194

PR: https://git.openjdk.org/valhalla/pull/1194


More information about the valhalla-dev mailing list