RFR: 8329531: compiler/c2/irTests/TestIfMinMax.java fails with IRViolationException: There were one or multiple IR rule failures.

Jasmine Karthikeyan jkarthikeyan at openjdk.org
Fri Apr 19 03:02:59 UTC 2024


On Wed, 17 Apr 2024 13:59:42 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> This patch fixes an issue with the `TestIfMinMax` IR test where specific random seeds cause the branch probability to be so low that the branch cannot CMove, causing the IR check to fail for min/max reductions. For example, if the first value returned by `Random#nextInt` was `int_min` then the branch will be only taken once, which works out to `1/512 => ~0.002`. This value is smaller than the CMove threshold `0.01`, so it cannot CMove.
>> I've added sequential values from 1 to 50 and -1 to -50 before inserting random values in the array, so there will be a guaranteed 50 successes and 50 failures for each run. I've also replaced the multiplication by two with an opaque multiplication by one to prevent the randomly generated numbers from becoming larger, like what the test `MinMaxRed_Int` does.
>> 
>> Thoughts and reviews would be appreciated!
>
> Looks reasonable, thanks for the fix!

Thanks for the review @eme64, and thanks for taking a look @dafedafe! I think the scope of the tests shouldn't be limited by this change. The vectorization IR test is the only test that takes the 1s as the right hand argument, and I think functionally the it should behave the same as the true/false ratio will still be roughly equal before and after. Before we were comparing `rand_int < rand_int`, which is true roughly 50% of the time. Comparing against 1 it should still be true roughly 50% of the time since `nextInt()` distributes ints across the whole domain.

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

PR Comment: https://git.openjdk.org/jdk/pull/18734#issuecomment-2065663984


More information about the hotspot-compiler-dev mailing list