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

Quan Anh Mai qamai at openjdk.org
Mon Jan 27 09:48:49 UTC 2025


On Sat, 25 Jan 2025 16:23:00 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.
>
> Johannes Graham has updated the pull request incrementally with three additional commits since the last revision:
> 
>  - formatting
>  - simplified version of bounds check
>  - tests for xor hi=power of 2

I would advise against adding more complicated jtreg tests as reasoning about them can be tricky. For these operations I think it would be more preferable to use a gtest which can directly inspect the details of `Type` objects while jtreg tests can only reason about them indirectly. You can generate some pairs of `Type`s, calculate their xor, then, try to sample some values inside the operands and assert that the results would be a member of the resulted `Type`.

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

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


More information about the hotspot-compiler-dev mailing list