RFR: 8347645: C2: XOR bounded value handling blocks constant folding
Emanuel Peter
epeter at openjdk.org
Wed Jan 22 07:57:34 UTC 2025
On Mon, 13 Jan 2025 22:16:20 GMT, Johannes Graham <duke at openjdk.org> wrote:
> C2 does not eliminate XOR nodes with constant arguments. This has a noticeable effect on `Long.expand` with a constant mask, on architectures that don't have instructions equivalent to `PDEP` to be used in an intrinsic.
>
> This patch demonstrates a potential fix to the problem, but there might well be better ways to do it.
Thanks for working on this!
I have not yet looked at the VM cpp changes yet.
Some comments about the test:
Please move it to:
`test/hotspot/jtreg/compiler/c2/gvn/TestXor.java`
The comments sometimes mention `c3` etc, but there may only be a `c` or `x`. Please fix them ;)
The tests should also do result verification. Currently you only check that we have the expected nodes, but constant folding could have bugs we would not catch this way. What I usually do:
Compute some `GOLDEN`, which should be computed in interpreter, and then with a `@Check` method you can compare the result to that `GOLDEN` value.
Plus: it would be nice if the constants could be picked at random. You can do that with a `public static final int CON = random_value`.
Best would be if you could use the new `Generators`, see
`./test/hotspot/jtreg/compiler/lib/generators/Generators.java`
Let me know if you need any more help with that.
-------------
PR Review: https://git.openjdk.org/jdk/pull/23089#pullrequestreview-2566427884
More information about the hotspot-compiler-dev
mailing list