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

Marc Chevalier duke at openjdk.org
Fri Mar 7 16:40:05 UTC 2025


On Fri, 7 Mar 2025 12:41:06 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/memnode.cpp line 3577:
> 
>> 3575:   if (val->Opcode() == Op_RShiftI) {
>> 3576:     const TypeInt* conIR = phase->type(val->in(2))->isa_int();
>> 3577:     if (conIR != nullptr && conIR->is_con() && (conIR->get_con() <= num_rejected_bits)) {
> 
> Can you say why you need `conIR->get_con() <= num_rejected_bits` in a comment?

Explained. It deserved a drawing.

> src/hotspot/share/opto/mulnode.cpp line 983:
> 
>> 981: static Node* collapse_nested_shift_left(PhaseGVN* phase, Node* outer_shift, int con0, BasicType bt) {
>> 982:   assert(bt == T_LONG || bt == T_INT, "Unexpected type");
>> 983:   int nbits = bt == T_LONG ? BitsPerJavaLong : BitsPerJavaInteger;
> 
> Roland is introducing a new method for this in `https://github.com/openjdk/jdk/pull/23438`, see `bits_per_java_integer`. I suggest you use it too ;)

Happily, as soon as this other PR is merged!

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

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


More information about the hotspot-compiler-dev mailing list