RFR: 8297715: RISC-V: C2: Use single-bit instructions from the Zbs extension
Fei Yang
fyang at openjdk.org
Thu Dec 1 06:03:17 UTC 2022
On Tue, 29 Nov 2022 06:48:25 GMT, Feilong Jiang <fjiang at openjdk.org> wrote:
>> The single-bit instructions from the Zbs extension provide a mechanism to set, clear,
>> invert, or extract a single bit in a register. The bit is specified by its index.
>>
>> Especially, the single-bit extract (immediate) instruction 'bexti rd, rs1, shamt' [1] performs:
>>
>> let index = shamt & (XLEN - 1);
>> X(rd) = (X(rs1) >> index) & 1;
>>
>>
>> This instruction is a perfect match for following C2 sub-graph when integer immediate 'mask' is power of 2:
>>
>> Set dst (Conv2B (AndI src mask))
>>
>>
>> The effect is that we could then optimize C2 JIT code for methods like [2]:
>> Before:
>>
>> lhu R28, [R11, #12] # short, #@loadUS ! Field: com/sun/org/apache/xerces/internal/dom/NodeImpl.flags
>> andi R7, R28, #8 #@andI_reg_imm
>> snez R10, R7 #@convI2Bool
>>
>>
>> After:
>>
>> lhu R28, [R11, #12] # short, #@loadUS ! Field: com/sun/org/apache/xerces/internal/dom/NodeImpl.flags
>> bexti R10, R28, 3 #
>>
>>
>> Testing: Tier1-3 hotspot & jdk tested with QEMU (JTREG="VM_OPTIONS=-XX:+UnlockExperimentalVMOptions -XX:+UseZbs").
>>
>> [1] https://github.com/riscv/riscv-bitmanip/blob/main/bitmanip/insns/bexti.adoc
>>
>> [2] https://github.com/openjdk/jdk/blob/master/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/NodeImpl.java#L1936
>
> Looks good.
@feilongjiang @yadongw : Thanks for looking at this. Need a Reviewer then. Maybe @shipilev ?
-------------
PR: https://git.openjdk.org/jdk/pull/11406
More information about the hotspot-compiler-dev
mailing list