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

Christian Hagedorn chagedorn at openjdk.org
Tue Aug 13 15:34:10 UTC 2024


On Tue, 6 Aug 2024 11:05:42 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

> 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

Thanks Tobias for your review!

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

PR Comment: https://git.openjdk.org/valhalla/pull/1194#issuecomment-2286536848


More information about the valhalla-dev mailing list