RFR: 8281518: New optimization: convert "(x|y)-(x^y)" into "x&y" [v2]

Andrew Dinn adinn at openjdk.java.net
Thu Feb 10 14:52:07 UTC 2022


On Wed, 9 Feb 2022 20:14:33 GMT, Zhiqiang Zang <duke at openjdk.java.net> wrote:

> I was wondering if there is a good way to benchmark the general cases where this pattern is few seen

It's very difficult to find a way to assess the positive and negative aspects of a change like this. Micro-benchmarks only really provide a ballpark guide to the *potential* benefit because they test the effect of the change in isolation. Even then they only tell part of the story because they ignore the degree to which that benefit will be realized. The potential costs are even harder to estimate. They will vary from app to app according to what gets compiled and which paths the compilation takes. They will even vary from run to run of the same app because the JVM does not guarantee precise repeatability across restarts even if you keep all inputs the same.

For quite a few ideal transformations it is clear that they will be applicable very frequently and hence that they are worth implementing. That's often clear because we know that frequently used Java language constructs translate to graphs that will have a shape that matches the input checked for by the ideal code. In other cases, we can know that related ideal transforms will recursively combine to generate the target shape. For many other possible transforms we are in a grey area where we cannot know if the cost of checking for will repay in saved execution.

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

PR: https://git.openjdk.java.net/jdk/pull/7395


More information about the hotspot-compiler-dev mailing list