RFR: 8364407: [REDO] Consolidate Identity of self-inverse operations

Manuel Hässig mhaessig at openjdk.org
Mon Aug 18 16:21:15 UTC 2025


On Mon, 18 Aug 2025 15:50:37 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

>> The previous approach was flawed for `short` and `char` as these are int-subtypes and truncate the result (see the backout issue https://bugs.openjdk.org/browse/JDK-8364409 for a reproducer).
>> 
>> This change now first ensures that the input type is small enough so no truncation gets lost when dropping the operations.
>> 
>> The previous implementation also used an `InvolutionNode` superclass with one `Identity(...)` implementation, but there were some reservations whether this is the right way to go. As we now have a `ReverseBytesNode`, there is also less benefit in having the supertype, as this covers 4 in 1 already.
>> 
>> I also added test cases on top of the original ones that ensure the nodes stay when we can't prove the input type is small enough.
>
> test/hotspot/jtreg/compiler/c2/gvn/InvolutionIdentityTests.java line 211:
> 
>> 209: 
>> 210:     @Test
>> 211:     @IR(counts = {IRNode.REVERSE_BYTES_S, "2"})
> 
> I'm not sure if this is fine. The intrinsics might not apply to all platforms, in which case this would fail I think?

The only case I can immediately think of is riscv without `-XX:+UseZbb`. But you can easily disable the test for that platform.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26823#discussion_r2282865605


More information about the hotspot-compiler-dev mailing list