RFR: 8364407: [REDO] Consolidate Identity of self-inverse operations
Hannes Greule
hgreule at openjdk.org
Mon Aug 18 15:57:56 UTC 2025
On Mon, 18 Aug 2025 15:49:48 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?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26823#discussion_r2282799804
More information about the hotspot-compiler-dev
mailing list