RFR: 8341328: Refactor initial Assertion Predicate creation into separate classes
Christian Hagedorn
chagedorn at openjdk.org
Thu Oct 10 09:14:39 UTC 2024
On Thu, 10 Oct 2024 09:04:21 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
> This PR refactors the initial Assertion Predicate creation (i.e. when initially creating them, not when copy/copy-updating them from existing Template Assertion Predicates).
>
> The patch includes the following changes:
> - `PhaseIdealLoop::add_template_assertion_predicate()`, `add_range_check_elimination_assertion_predicate()`and the preparation code to call it, and `clone_template_assertion_predicate()` have similar code. I tried to share the common bits with new classes:
> - `TemplateAssertionPredicateCreator`: Creates a new Template Assertion Predicate either with an UCT (done in Loop Predication) or a Halt node (done in Range Check Elimination).
> - `InitializedAssertionPredicateCreator`: Creates a new Initialized Assertion Predicate with a Halt Node. This is an existing class which provided a method to clone a Template Assertion Predicate expression and create a new Initialized Assertion Predicate with it. Now it's extended to create one without an existing template.
> - `AssertionPredicateIfCreator`: Used by both classes above and also by `clone_template_assertion_predicate()` (it clones the Assertion Predicate expression first and then just needs to create the `If`)
> - `AssertionPredicateExpressionCreator`: Create a new Assertion Predicate expression, either with an `Opaque4` (for Template Assertion Predicates) or an `OpaqueInitializedAssertionPredicate` (for Initialized Assertion Predicates).
> - Some renaming to get more consistency (e.g. use `new_control` instead of `control` or `new_ctrl`)
> - Adding new `AssertionPredicateType::FinalIv` which was missed to account for in [JDK-8335393](https://bugs.openjdk.org/browse/JDK-8335393) where a new Initialized Assertion Predicate was added for the final IV in Range Check Elimination for a special case when removing an empty main loop.
>
> Thanks,
> Christian
src/hotspot/share/opto/loopPredicate.cpp line 1277:
> 1275: IfTrueNode* template_assertion_predicate_proj =
> 1276: create_template_assertion_predicate(if_opcode, cl, parse_predicate_proj, upper_bound_proj, scale, offset, range,
> 1277: deopt_reason);
We only use the opcode from the `iff`. `init`, `limit` and `stride` can be fetched from the `CountedLoop` again.
src/hotspot/share/opto/loopTransform.cpp line 3088:
> 3086: set_ctrl(iffm->in(1), new_limit_ctrl);
> 3087:
> 3088: C->print_method(PHASE_AFTER_RANGE_CHECK_ELIMINATION, 4, cl);
Moved this down because we missed some transformations when having this earlier. Additionally, if there are multiple range checks, we can see the intermediate state for one transformation with the next `PHASE_BEFORE_RANGE_CHECK_ELIMINATION` dump.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21446#discussion_r1795020752
PR Review Comment: https://git.openjdk.org/jdk/pull/21446#discussion_r1795027412
More information about the hotspot-compiler-dev
mailing list