RFR: 8347459: C2: missing transformation for chain of shifts/multiplications by constants [v5]

Marc Chevalier duke at openjdk.org
Fri Mar 7 14:29:24 UTC 2025


On Fri, 7 Mar 2025 12:59:22 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Marc Chevalier has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   + comment on why not zerocon
>
> src/hotspot/share/opto/mulnode.cpp line 980:
> 
>> 978: // con0 is the rhs of outer_shift (since it's already computed in the callers)
>> 979: // con0 is assumed to be masked already (as computed by maskShiftAmount) and non-zero
>> 980: // bt must be T_LONG or T_INT.
> 
> Suggestion:
> 
> // We have:
> //   outer_shift = (_ << con0)
> // We are looking for the pattern:
> //   outer_shift = (inner_shift << con0)
> //   outer_shift = ((x << con1) << con0)
> //
> // if con0 + con1 >= nbits => 0
> // if con0 + con1 < nbits => x << (con1 + con0)
> //
> // Note: con0 and con1 are both in [0..nbits), as they are computed by maskShiftAmount.
> 
> `bt must be T_LONG or T_INT.` is already stated by the assert.
> 
> This is just a suggestion, take/modify/ignore it as you wish ;)

I took and modified slightly.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23728#discussion_r1985147031


More information about the hotspot-compiler-dev mailing list