RFR: 8344035: Replace predicate walking code in Loop Unswitching with a predicate visitor [v2]

Roland Westrelin roland at openjdk.org
Thu Jan 9 12:55:50 UTC 2025


On Mon, 6 Jan 2025 10:08:13 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> This patch is a follow up to the clean-ups done with [JDK-8342945](https://bugs.openjdk.org/browse/JDK-8342945) and introduces a new predicate visitor for Loop Unswitching to update the last remaining custom predicate cloning code.
>> 
>> This patch includes the following:
>> 
>> - New `CloneUnswitchedLoopPredicatesVisitor` class which delegates the cloning work to a new `ClonePredicateToTargetLoop` class.
>>   - We walk the predicate chain in the `PredicateIterator` and call the `CloneUnswitchedLoopPredicatesVisitor` for each visited predicate. Then we clone the predicate on the fly to the target loop.
>> - New `ClonePredicateToTargetLoop` class:
>>   - Clones Parse Predicates
>>   - Clones Template Assertion Predicates
>>     - Includes rewiring of control dependent data nodes
>>   - Rewires the cloned predicates to the target loop with new `TargetLoopPredicateChain` class:
>>     - Keeps track of the current chain head, which is the target loop itself when the chain is still empty.
>>     - Each time a new predicate is inserted at the target loop, the old predicate chain head is set as output of the new predicate.
>>     - An example is shown as class comment at `TargetLoopPredicateChain`.
>>     - I plan to reuse this class later again when also updating `CreateAssertionPredicatesVisitor` which is done when we tackle the actual still remaining Assertion Predicate bugs.
>> - Removal of custom predicate cloning code found in `PhaseIdealLoop`.
>> - Changed steps performed in Loop Unswitching from:
>>   1. Clone loop
>>   2. Clone predicates and insert them below the unswitched loop selector If projections
>>   3. Connect the cloned predicates to the unswitched loops
>> 
>>   to:
>> 
>>   1. Clone loop
>>   2. Connect unswitched loop selector If projections to unswitched loops such that they are now the new loop entries
>>   3. Clone predicates and insert them between the unswitched loop selector If projections and the unswitched loops
>> - Rename/update `get_template_assertion_predicates()`/`TemplateAssertionPredicateCollector` to reflect the only use left.
>> 
>> Thanks,
>> Christian
>
> Christian Hagedorn has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8344035
>  - 8344035: Replace predicate walking code in Loop Unswitching with a predicate visitor

Looks good to me.

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

Marked as reviewed by roland (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/22828#pullrequestreview-2539842846


More information about the hotspot-compiler-dev mailing list