RFR: 8340786: Introduce Predicate classes with predicate iterators and visitors for simplified walking [v3]
Roland Westrelin
roland at openjdk.org
Fri Sep 27 12:55:38 UTC 2024
On Thu, 26 Sep 2024 07:42:54 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> This patch introduces new predicate classes which implement a new `Predicate` interface. These classes represent the different predicates in the C2 IR. They are used in combination with new predicate iterator and visitors classes to provide an easy way to walk and process predicates in the IR.
>>
>> ### Predicate Interfaces and Implementing Classes
>> - `Predicate` interface is implemented by four predicate classes:
>> - `ParsePredicate` (existing class)
>> - `RuntimePredicate` (existing and updated class)
>> - `TemplateAssertionPredicate` (new class)
>> - `InitializedAssertionPredicate` (new class, renamed old `InitializedAssertionPredicate` class to `InitializedAssertionPredicateCreator`)
>>
>> ### Predicate Iterator with Visitor classes
>> There is a new `PredicateIterator` class which can be used to iterate through the predicates of a loop. For each predicate, a `PredicateVisitor` can be applied. The user can implement the `PredicateIterator` interface and override the default do-nothing implementations to the specific needs of the code. I've done this for a couple of places in the code by defining new visitors:
>> - `ParsePredicateUsefulMarker`: This visitor marks all Parse Predicates as useful.
>> - Replaces the old now retired `ParsePredicateIterator`.
>> - `DominatedPredicates`: This visitor checks the dominance relation to an `early` node when trying to figure out the latest legal placement for a node. The goal is to skip as many predicates as possible to avoid interference with Loop Predication and/or creating a Loop Limit Check Predicate.
>> - Replaces the old now retired `PredicateEntryIterator`.
>> - `Predicates::dump()`: Newly added dumping code for the predicates above a loop which uses a new `PredicatePrinter` visitor. This helps debugging issues with predicates.
>>
>> #### To Be Replaced soon
>> There are a couple of places where we use similar code to walk predicates and apply some transformation/modifications to the IR. The goal is to replace these locations with the new visitors as well. This will incrementally be done with the next couple of PRs.
>>
>> ### More Information
>> More information about specific classes and changes can be found as code comments and PR comments.
>>
>> Thanks,
>> Christian
>
> Christian Hagedorn has updated the pull request incrementally with one additional commit since the last revision:
>
> Add missing public for UnifiedPredicateVisitor
That looks reasonable to me.
src/hotspot/share/opto/loopnode.cpp line 4325:
> 4323: class ParsePredicateUsefulMarker : public PredicateVisitor {
> 4324: public:
> 4325: using PredicateVisitor::visit;
Why is this needed?
-------------
Marked as reviewed by roland (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/21161#pullrequestreview-2333671087
PR Review Comment: https://git.openjdk.org/jdk/pull/21161#discussion_r1778576842
More information about the hotspot-compiler-dev
mailing list