RFR: 8346552: C2: Add IR tests to check that Predicate cloning in Loop Unswitching works as expected [v6]
Manuel Hässig
duke at openjdk.org
Tue Apr 22 13:28:58 UTC 2025
On Tue, 22 Apr 2025 12:59:30 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
>
> Manuel Hässig has updated the pull request incrementally with one additional commit since the last revision:
>
> Apply missing suggestion
>
> Co-authored-by: Christian Hagedorn <christian.hagedorn at oracle.com>
All your comments and suggestions should be addressed. Thanks!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24479#issuecomment-2821330249
More information about the hotspot-compiler-dev
mailing list