RFR: 8370196: C2: Improve (U)MulHiLNode::MulHiValue [v5]

Hannes Greule hgreule at openjdk.org
Tue Nov 18 15:44:45 UTC 2025


On Tue, 18 Nov 2025 15:23:24 GMT, Zihao Lin <duke at openjdk.org> wrote:

>> If nodes both are constant, support constant folding.
>
> Zihao Lin has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Apply suggestion from @eme64
>   
>   Co-authored-by: Emanuel Peter <emanuel.peter at oracle.com>

Looks mostly good, and I'm fine with addressing more general implementations separately. There is some code duplication now, which could probably avoided using templates, but I'm not sure if that's any cleaner. If no one else has a problem with the duplication, we can leave it as-is.
Edit: I see @eme64 had similar thoughts :)

src/hotspot/share/opto/mulnode.cpp line 641:

> 639:   // Both are constant, directly computed the result
> 640:   if (longType1->is_con() && longType2->is_con()) {
> 641:     jlong highResult = multiply_high_unsigned(longType1->get_con(), longType2->get_con());

We are going from an unsigned value to a signed here, I think this is implementation-defined? Maybe it's better to use julong and `TypeLong::make_or_top(TypeIntPrototype<jlong, julong>{{min_jlong, max_jlong}, {highResult, highResult}, {0, 0}})`?

(It might also make sense to have a helper function like `TypeLong::make_unsigned` for that, but I'll let others comment on whether that should be done separately)

test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java line 1533:

> 1531:     public static final String MUL_HI_L = PREFIX + "MUL_HI_L" + POSTFIX;
> 1532:     static {
> 1533:         superWordNodes(MUL_HI_L, "MulHiL");

This looks wrong, and I think it might make more sense to move these definitions closer to MUL_L.

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

PR Review: https://git.openjdk.org/jdk/pull/28097#pullrequestreview-3478392898
PR Review Comment: https://git.openjdk.org/jdk/pull/28097#discussion_r2538693102
PR Review Comment: https://git.openjdk.org/jdk/pull/28097#discussion_r2538642420


More information about the hotspot-compiler-dev mailing list