RFR: 8353551: C2: Constant folding for ReverseBytes nodes

Johannes Graham duke at openjdk.org
Sun Apr 6 13:42:48 UTC 2025


On Sat, 5 Apr 2025 08:52:49 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

>> src/hotspot/share/opto/subnode.cpp line 2025:
>> 
>>> 2023: 
>>> 2024: template<typename T, BasicType B>
>>> 2025: const Type* reverse_bytes(const Node* node, PhaseGVN* phase) {
>> 
>> Could this be templated with TypeLong/TypeInt instead of BasicType? There is a `try_cast` that @merykitty added in https://github.com/openjdk/jdk/pull/17508 that might help.
>
> It wouldn't change much, but yes. Generally this is an example where #17508 shines, as the code could be generalized to just reverse the bytes of the KnownBits structure. Whether this PR waits until then or we refactor the code afterwards isn't that important to me.

I didn’t intend to advocate for waiting for that PR. `try_cast` is tiny and could be added independently. I have just been looking for things that could generally help with unifying TypeInt/TypeLong implementations.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24382#discussion_r2030155751


More information about the hotspot-compiler-dev mailing list