RFR: 8347645: C2: XOR bounded value handling blocks constant folding [v33]

Emanuel Peter epeter at openjdk.org
Wed Feb 26 06:53:56 UTC 2025


On Tue, 25 Feb 2025 16:22:11 GMT, Johannes Graham <duke at openjdk.org> wrote:

>> I started down the path of more elaborate randomization (see code removed in https://github.com/openjdk/jdk/pull/23089/commits/4a2912021103cefbe30fb3cc9e7d303b63ea454d). Instead of that approach. I went with doing the more detailed coverage with gtest, and having just a few specific checks in the IR tests. For example the "pow2" tests are there because that was a scenario that caused some trouble. I think there is a relatively small set of "interesting" cases that are nice to cover with something deterministic. (I could add a few more tests with hard-coded interesting values). It feels disproportionate to do something more complicated for this PR. 
>> 
>> That said, if there was more tooling in place to make more broad random tests easier to write, it would be very attractive. Looking at PR https://github.com/openjdk/jdk/pull/23418, it looks like that's what you've got in mind. Specifically, these kinds of tests with constants are begging for a way to spew out a whole bunch of related test methods.
>
> Also, as you commented on somewhere above, having a way to target Types from a stand-alone gtest, would also be a really nice way of making things more testable.

> For example the "pow2" tests are there because that was a scenario that caused some trouble. I think there is a relatively small set of "interesting" cases that are nice to cover with something deterministic. (I could add a few more tests with hard-coded interesting values).

I know that there are only few "interesting" cases. That's why I came up with `Generators` so we would be more likely to hit the interesting cases.

Of course we want to have a good number of deterministic cases. But extending that with some randomized tests that would find bugs over a longer time span are still valuable.

The issue is often that there are edge cases, and humans are not very good at finding them. Thus with randomization we would at least eventually find those cases - hopefully. And in my experience I did find bugs with randomized tests. Sometimes we found bugs that were not related to the issue they were created for originally, but they found some other issue - and that is valuable too.

> It feels disproportionate to do something more complicated for this PR.

It's really not that complicated. All I'd be asking for is the test in the form that I provided above ;)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23089#discussion_r1971030846


More information about the hotspot-compiler-dev mailing list