Integrated: 8346552: C2: Add IR tests to check that Predicate cloning in Loop Unswitching works as expected
Manuel Hässig
duke at openjdk.org
Thu Apr 24 08:31:54 UTC 2025
On Mon, 7 Apr 2025 07:49:08 GMT, Manuel Hässig <duke at openjdk.org> wrote:
> # Issue Summary
>
> When a loop is unswitched, all parse predicates from the original loop must be cloned to the second loop that is created. Forgetting to clone a parse predicate is a common error during development on loop unswitching code that we could not catch previously. Since we have the IR-framework now, this PR introduces a test to catch this error.
>
> # Changes
>
> The main contribution of this PR is a test to ensure that all predicates have been cloned into an unswitched loop.
> Working on this PR revealed that Loop Limit Check Parse Predicates are erroneously cloned when unswitching counted loops. That is because we know that the loop variable increments monotonously in counted loops, so a loop limit check at the loop selector is sufficient for both unswitched loops. However, for uncounted loops we do not know anything about the behavior of the loop variables and they could behave differently in either of the unswitched loops. Hence, cloning the loop limit check is needed in that case. This PR also removes the superfluous cloning.
>
> All changes summarized:
> - add `OPAQUE_TEMPLATE_ASSERTION_PREDICATE_NODE` to the IR-framework,
> - add some missing parse predicate nodes to the IR-framework,
> - change the output of the labels of parse predicate nodes in the ideal graph so they can be recognized reliably by the IR-framework (the main problem was that `Loop ` is a prefix of `Loop Limit Check` that is hard to distinguish with spaces instead of underlines),
> - rework the regex for detecting parse predicates in the IR-framework,
> - add a test to ensure parse predicates are cloned into unswitched loops,
> - only clone loop limit checks when unswitching uncounted loops,
> - add a test which checks that loop limit checks are not cloned when unswitching counted loops,
> - add a test which checks that loop limit checks are cloned when unswitching uncounted loops.
>
> # Testing
>
> - [Github Actions](https://github.com/mhaessig/jdk/actions/runs/14266369099)
> - tier1 through tier3 plus Oracle internal testing
This pull request has now been integrated.
Changeset: 84e9264e
Author: Manuel Hässig <manuel.hassig at oracle.com>
Committer: Christian Hagedorn <chagedorn at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/84e9264e76ca6e5d984c8eecbf5c5d11128fc174
Stats: 222 lines in 5 files changed: 214 ins; 1 del; 7 mod
8346552: C2: Add IR tests to check that Predicate cloning in Loop Unswitching works as expected
Co-authored-by: Christian Hagedorn <chagedorn at openjdk.org>
Reviewed-by: chagedorn, epeter
-------------
PR: https://git.openjdk.org/jdk/pull/24479
More information about the hotspot-compiler-dev
mailing list