RFR: 8347645: C2: XOR bounded value handling blocks constant folding

Hannes Greule hgreule at openjdk.org
Wed Jan 15 21:38:51 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.

The code for this optimization seems to be present already in the `add_ring` methods, and from my understanding those should be called by `AddNode::Value`. Does that mean `XorINode::Value` and `XorLNode::Value` never call that method in your tests, and instead always end up in the `if` directly below your changes? Maybe that `if` should rather check to ignore constant values? Alternatively, that `if` could be moved into the `add_ring` methods too maybe?

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

PR Comment: https://git.openjdk.org/jdk/pull/23089#issuecomment-2589204936


More information about the hotspot-compiler-dev mailing list