RFR: 8370196: C2: Improve (U)MulHiLNode::MulHiValue
Hannes Greule
hgreule at openjdk.org
Sun Nov 2 09:56:00 UTC 2025
On Sat, 1 Nov 2025 14:50:27 GMT, Zihao Lin <duke 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.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28097#issuecomment-3477676797
More information about the hotspot-compiler-dev
mailing list