RFR: 8350988: Consolidate Identity of self-inverse operations [v2]

Emanuel Peter epeter at openjdk.org
Thu Mar 13 13:23:54 UTC 2025


On Thu, 13 Mar 2025 13:16:31 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

>> test/hotspot/jtreg/compiler/c2/irTests/InvolutionIdentityTests.java line 83:
>> 
>>> 81:         assertResultF(nanf);
>>> 82: 
>>> 83:         double ad = RunInfo.getRandom().nextDouble();
>> 
>> This actually only generates values between `0.0...1.0`.
>> 
>> Can you instead use `Generators.java`? It will make sure to generate "interesting" values, including different encodings of `NaN`, infinity, etc.
>
> Good catch, I'm using Generators now. I'm currently not testing ReverseBytesS/US, but there also isn't support for short/char in Generators. Should I still add tests?

You can always restrict ranges:

private static final RestrictableGenerator<Integer> GEN_BYTE = Generators.G.safeRestrict(Generators.G.ints(), Byte.MIN_VALUE, Byte.MAX_VALUE);
private static final RestrictableGenerator<Integer> GEN_CHAR = Generators.G.safeRestrict(Generators.G.ints(), Character.MIN_VALUE, Character.MAX_VALUE);
private static final RestrictableGenerator<Integer> GEN_SHORT = Generators.G.safeRestrict(Generators.G.ints(), Short.MIN_VALUE, Short.MAX_VALUE);
private static final RestrictableGenerator<Integer> GEN_INT = Generators.G.ints();
private static final RestrictableGenerator<Long> GEN_LONG = Generators.G.longs();
private static final Generator<Float> GEN_FLOAT = Generators.G.floats();
private static final Generator<Double> GEN_DOUBLE = Generators.G.doubles();
private static final RestrictableGenerator<Integer> GEN_BOOLEAN = Generators.G.safeRestrict(Generators.G.ints(), 0, 1);


> I'm currently not testing ReverseBytesS/US, but there also isn't support for short/char in Generators. Should I still add tests?

And yes, more tests would always be better.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23851#discussion_r1993509063


More information about the hotspot-compiler-dev mailing list