RFR: 8353551: C2: Constant folding for ReverseBytes nodes

Hannes Greule hgreule at openjdk.org
Sat Apr 5 08:55:48 UTC 2025


On Fri, 4 Apr 2025 17:22:34 GMT, Johannes Graham <duke at openjdk.org> wrote:

>> This change implements constant folding for ReverseBytes nodes.
>> 
>> Currently, `byteswap` is included transitively by `reverse_bits.hpp`. I'm not sure if this is fine or if I need to add an explicit include there.
>> 
>> I appreciate any reviews and comments.
>
> 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.

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

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


More information about the hotspot-compiler-dev mailing list