RFR: 8325746: Refactor Loop Unswitching code [v7]

Emanuel Peter epeter at openjdk.org
Fri Feb 16 08:19:10 UTC 2024


On Fri, 16 Feb 2024 08:16:11 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> To simplify the review of https://github.com/openjdk/jdk/pull/16877, I've decided to split off some code into separate sub-tasks.
>> 
>> This sub-task focuses on the code refactoring done in Loop Unswitching. I've incorporated the feedback from @eme64 at https://github.com/openjdk/jdk/pull/16877 in the proposed changes.
>> 
>> #### Changes
>> - Adding a more detailed description about the Loop Unswitching optimization itself below the file header.
>> - Renaming `fast loop` -> `true-path-loop` and `slow loop` -> `false-path-loop` since we don't really know which one is faster and to avoid keeping a mental map of which path goes into which unswitched loop version.
>> - Creating new classes:
>>   - `UnswitchedLoopSelector` to create the unswitched loop selector `If` (i.e. the If node that selects at runtime which unswitched loop version is executed) based on the invariant and non-loop-exiting unswitch candidate `If`.
>>   - `OriginalLoop` to do the actual unswitching (i.e. loop cloning, predicates cloning and fixing the graph to the loop selector `If`).
>> - Extracting methods in `do_unswitching()` to clean it up further.
>> - Improving `TraceLoopUnswitching` result printing.
>> - Adding some shared utility methods.
>> 
>> #### Possible Follow-Up RFEs
>> There are possible follow-up opportunities to further improve the loop unswitching which, however, would go to far in the context of fixing Assertion Predicates. We could follow up with RFEs to tackle these:
>> - At some point it might be good to have a dedicated `LoopUnswitching` class to split all the methods off from `PhaseIdealLoop`. This would also avoid noisy "loop_unswitching" prefixes.
>> - Bailout code in `has_control_dependencies_from_predicates()` is too conservative. I have already some code to improve that in the full fix for Assertion Predicates which I plan to split off and propose separatly.
>> - `TraceLoopUnswitching` currently only prints the result and if it failed. We might want to improve that in the future to cover more steps to make it useful for debugging (would require some more fine-grained debug levels, though).
>
> Christian Hagedorn has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update src/hotspot/share/opto/loopUnswitch.cpp
>   
>   Co-authored-by: Emanuel Peter <emanuel.peter at oracle.com>

Marked as reviewed by epeter (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/17842#pullrequestreview-1884531514


More information about the hotspot-compiler-dev mailing list