RFR: 8350177: C2 SuperWord: Integer.numberOfLeadingZeros, numberOfTrailingZeros, reverse and bitCount have input types wrongly turncated for byte and short [v2]

Jasmine Karthikeyan jkarthikeyan at openjdk.org
Wed Jun 4 04:34:16 UTC 2025


On Wed, 28 May 2025 07:41:09 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> src/hotspot/share/opto/superword.cpp line 2496:
>> 
>>> 2494:   int opc = in->Opcode();
>>> 2495:   return opc == Op_AddI || opc == Op_SubI || opc == Op_MulI || opc == Op_AndI || opc == Op_OrI || opc == Op_XorI
>>> 2496:     || opc == Op_ReverseBytesS || opc == Op_ReverseBytesUS;
>> 
>> A switch might look nicer here, and be easier to extend later on ;)
>
> This list is a little scary... how do we know that we have all cases in it, and we are not getting regressions because we are missing some?

A switch is a good idea, it'll definitely make the code easier to read. I've made the change in the recent commit. As for the cases, I ended up running the compiler unit tests and modifying the list until there were no test failures. Since we check for nodes that do not need truncation handling, any other nodes will automatically default to require truncation handling and fall back to not vectorizing.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25440#discussion_r2125610158


More information about the hotspot-compiler-dev mailing list