RFR: 8349563: Improve AbsNode::Value() for integer types [v3]

Emanuel Peter epeter at openjdk.org
Thu Jul 3 05:30:40 UTC 2025


On Thu, 3 Jul 2025 03:38:13 GMT, Jasmine Karthikeyan <jkarthikeyan at openjdk.org> wrote:

>> @jaskarth Nice work! I have a few comments below.
>> 
>> One is about more randomized tests. I'm thinking about something like this:
>> 
>> - compute `res = Math.abs(x)`
>> - Truncate `x` with randomly produced bounds from Generators, like this: `x = Math.max(lo, Math.min(hi, x))`.
>> - Below, add all sorts of comparisons with random constants, like this: `if (res < CON) { sum += 1; }`. If the output range is wrong, this could wrongly constant fold, and allow us to catch that.
>> - Then fuzz the generated method a few times with random inputs for `x`, and check that the sum and res value are the same for compiled and interpreted code.
>> 
>> I hope that makes sense :)
>> This is currently my best method to check if ranges are correct, and I think it is quite important because often tests are only written with constants in mind, but less so with ranges, and then we mess up the ranges because it is just too tricky.
>> 
>> This is an example, where I asked someone to try this out as well:
>> https://github.com/openjdk/jdk/pull/23089/files#diff-12bebea175a260a6ab62c22a3681ccae0c3d9027900d2fdbd8c5e856ae7d1123R404-R422
>
> @eme64 Thanks for the review and comments! The method of checking for constant folding with if statements and range filtering you mentioned is pretty clever. I've adapted it to the test and added it to the PR. Let me know what you think!

@jaskarth Nice, thanks for adding the range tests! Unfortunately, I'm quite busy before going on vacation. I hope someone else can review this. Otherwise I can come back to it in August.

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

PR Comment: https://git.openjdk.org/jdk/pull/23685#issuecomment-3030813369


More information about the hotspot-compiler-dev mailing list