RFR: JDK-8323497: On x64, use 32-bit immediate moves for narrow klass base if possible

Aleksey Shipilev shade at openjdk.org
Tue Jan 30 11:51:50 UTC 2024


On Wed, 10 Jan 2024 10:14:03 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Hmm, movptr only works its magic if the input is smaller than signed int max (2gb), and it needs one byte more than my variant.
>> 
>> base < 2g:
>> 
>> 
>>    35  ;; decode_klass_not_null
>>    36   0x00007efdcc9e51c4:   mov    $0x27000000,%r11                                                                                                                                                                                                                               
>>    37   0x00007efdcc9e51cb:   add    %r11,%r10
>> 
>> 
>> base > 2g:
>> 
>> 
>>    35  ;; decode_klass_not_null
>>    36   0x00007ff7a89e51c4:   movabs $0x82000000,%r11
>>    37   0x00007ff7a89e51ce:   add    %r11,%r10
>
> FYI the logic for immediate matching is:
> 
>     if (is_uimm32(imm)) {
>         movl(dst, imm);
>     } else if (is_simm32(imm)) {
>         movq(dst, imm);
>     } else {
>         mov64(dst, imm);
>     }
> 
> The reason is that `movl` is smaller than `movq` in code size.
> 
> Maybe we can change `movptr` to this. I hope that I do not miss anything here.

Yeah, current `movptr` is sign-extending 32->64, which is not extra-efficient for 32-bit unsigned imms with highest bit set. I think we can indeed check for `is_uimm32` in `movptr` to cover that case too.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17340#discussion_r1447171865


More information about the hotspot-dev mailing list