RFR: 8346552: C2: Add IR tests to check that Predicate cloning in Loop Unswitching works as expected [v2]
Christian Hagedorn
chagedorn at openjdk.org
Thu Apr 17 06:23:35 UTC 2025
On Thu, 10 Apr 2025 14:54:43 GMT, Manuel Hässig <duke at openjdk.org> wrote:
>> test/hotspot/jtreg/compiler/loopopts/TestUnswitchPredicateCloning.java line 64:
>>
>>> 62: @Test
>>> 63: // Check that loop unswitching the number of parse predicates inside the unswitched
>>> 64: // loop have doubled.
>>
>> Suggestion:
>>
>> // Check that Loop Unswitching doubled the number of Parse Predicates: We have them at the true- and false-path-loop. Note that the Loop Limit Check Parse Predicate is not cloned when we already have a counted loop.
>>
>>
>> While writing this suggestion, I think it would also be good to have the following tests:
>> - A test where we unswitch a `LoopNode` (i.e. non-counted) to check that the Loop Limit Check Parse Predicate is also cloned to both unswitched loop versions.
>> - Since you already added some verification for Assertion Predicates as well, I suggest to go a step further. We could add a test where we first apply Loop Predication and then Loop Unswitching to check if the number of Template Assertion Predicates also doubled. Here we need to be careful that we don't miscount. We only mark the old Template Assertion Predicates useless in Loop Unswitching and then clean them up in IGVN. So, we would need to check before loop opts phase `n`: `x` Template Assertion Predicates and then before loop opts phase `n + 1`: `2*x` Template Assertion Predicates.
>>
>> You could then update the issue/PR title to:
>> C2: Add IR tests to check that predicate cloning in Loop Unswitching works as expected.
>
> I committed your suggestion in 0a4d89ff57c.
>
> However, in this test the unswitched is a counted loop and yet the loop limit checks are cloned. I think this test has already found a bug?
Good catch! That's indeed a bug and must have been broken during my Assertion Predicates refactorings. Writing the test already paid off :-)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24479#discussion_r2037660275
More information about the hotspot-compiler-dev
mailing list