RFR: 8370196: C2: Improve (U)MulHiLNode::MulHiValue

Zihao Lin duke at openjdk.org
Sun Nov 16 15:54:24 UTC 2025


On Sun, 2 Nov 2025 09:53:40 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

>> If nodes both are constant, support constant folding.
>
> Thanks for working on this. A few things:
> 
> - You need tests to cover this change. The `Math.multiplyHigh(...)` and `Math.unsignedMultiplyHigh(...)` methods can be used to test this from the Java world. See e.g., #26143 or #25254 for inspiration.
> - The current method is for both unsigned and signed multiplication. You either have to deal with that directly there or get rid of that method and implement it directly in the respective `Value(...)` methods (the latter might be cleaner imo).
> - For unsigned multiplication, you can use the unsigned bounds (_uhi, _ulo)
> - I think extending from simple constant folding to intervals isn't that much more work. From my understanding, there shouldn't be any overflows that need to be handled. This would also automatically deal with cases like `multiplyHigh(x, 0)` etc.
> - The bottom checks are unneeded and can be removed (in fact, they would otherwise prevent proper calculation of the previous example)
> - Make sure to follow the code style: `T* v`; `if (a) {` spacing.

Hi @SirYwell 
Thanks for your comments. I change both Value method and add the relevant unit tests. Can you help to check if my understanding is correct? Thank you.

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

PR Comment: https://git.openjdk.org/jdk/pull/28097#issuecomment-3538892058


More information about the hotspot-compiler-dev mailing list