RFR: 8344171: Clone and initialize Assertion Predicates in order instead of in reverse-order

Christian Hagedorn chagedorn at openjdk.org
Wed Nov 20 12:49:05 UTC 2024


On Wed, 20 Nov 2024 12:40:58 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

> (Note: This is a dependent PR on https://github.com/openjdk/jdk/pull/22136 which is not fully reviewed, yet, but I'd like to already send this PR out for review since I'm away for the rest of the week)
> 
> This patch changes the order in which we clone and initialize Assertion Predicates from "reverse-order" to "in-order".
> 
> #### Current State: Mostly "reverse-order" for Assertion Predicates
> We are currently cloning and initializing Assertion Predicates in reverse-order out of convenience and simplicity for most of the loop splitting optimizations - except for Loop Unswitching (see next section). This means that we do the following:
> 
>                                      old target loop entry
>                                                |
>          x                         Cloned Template Assertion
>          |                                Predicate 2
> Template Assertion                             |
>     Predicate 1                       Initialized Assertion
>          |               ==>               Predicate 2
> Template Assertion                             |
>     Predicate 2                    Cloned Template Assertion
>          |                                Predicate 1
>     source loop                                |
>                                       Initialized Assertion
>                                            Predicate 1
>                                                |
>                                           target loop
> 
> I don't think this is wrong but still kinda unexpected when trying to reason about a graph. But now with the recent refactorings, I think it's easy to change this to an in-order processing:
> 
>                                      old target loop entry
>                                                |
>          x                          Cloned Template Assertion
>          |                                Predicate 1
> Template Assertion                             |
>     Predicate 1                       Initialized Assertion
>          |               ==>               Predicate 1
> Template Assertion                             |
>     Predicate 2                     Cloned Template Assertion
>          |                                Predicate 2
>     source loop                                |
>                                       Initialized Assertion
>                                            Predicate 2
>                                                |
>                                           target loop
> 
>  This will also align all cloni...

src/hotspot/share/opto/loopTransform.cpp line 1769:

> 1767:     _igvn.replace_input_of(target_outer_loop_head, LoopNode::EntryControl, last_created_predicate_success_proj);
> 1768:     set_idom(target_outer_loop_head, last_created_predicate_success_proj, dom_depth(target_outer_loop_head));
> 1769:   }

Workflow before was: Reverse-order cloning, so the very last clone needs to be connected to the loop head which was done here. With in-order, we can take care of the rewiring in the predicate visitor itself.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22275#discussion_r1850251858


More information about the hotspot-compiler-dev mailing list