Skip to content

Commit

Permalink
8297715: RISC-V: C2: Use single-bit instructions from the Zbs extension
Browse files Browse the repository at this point in the history
  • Loading branch information
DingliZhang committed Mar 27, 2023
1 parent bec4243 commit b9d856f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hotspot/cpu/riscv/assembler_riscv.hpp
Expand Up @@ -2004,7 +2004,7 @@ enum Nf {

// ====================================
// RISC-V Bit-Manipulation Extension
// Currently only support Zba and Zbb.
// Currently only support Zba, Zbb and Zbs bitmanip extensions.
// ====================================
#define INSN(NAME, op, funct3, funct7) \
void NAME(Register Rd, Register Rs1, Register Rs2) { \
Expand Down Expand Up @@ -2079,6 +2079,7 @@ enum Nf {

INSN(rori, 0b0010011, 0b101, 0b011000);
INSN(slli_uw, 0b0011011, 0b001, 0b000010);
INSN(bexti, 0b0010011, 0b101, 0b010010);

#undef INSN

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/riscv/globals_riscv.hpp
Expand Up @@ -94,6 +94,7 @@ define_pd_global(intx, InlineSmallCode, 1000);
product(bool, UseRVC, false, EXPERIMENTAL, "Use RVC instructions") \
product(bool, UseZba, false, EXPERIMENTAL, "Use Zba instructions") \
product(bool, UseZbb, false, EXPERIMENTAL, "Use Zbb instructions") \
product(bool, UseZbs, false, EXPERIMENTAL, "Use Zbs instructions") \
product(bool, UseRVVForBigIntegerShiftIntrinsics, true, \
"Use RVV instructions for left/right shift of BigInteger")

Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/cpu/riscv/riscv.ad
Expand Up @@ -2908,6 +2908,14 @@ operand immI_16bits()
interface(CONST_INTER);
%}

operand immIpowerOf2() %{
predicate(is_power_of_2((juint)(n->get_int())));
match(ConI);
op_cost(0);
format %{ %}
interface(CONST_INTER);
%}

// Long Immediate: low 32-bit mask
operand immL_32bits()
%{
Expand Down
14 changes: 14 additions & 0 deletions src/hotspot/cpu/riscv/riscv_b.ad
Expand Up @@ -523,5 +523,19 @@ instruct ornL_reg_reg_b(iRegLNoSp dst, iRegL src1, iRegL src2, immL_M1 m1) %{
as_Register($src2$$reg));
%}

ins_pipe(ialu_reg_reg);
%}

// AndI 0b0..010..0 + ConvI2B
instruct convI2Bool_andI_reg_immIpowerOf2(iRegINoSp dst, iRegIorL2I src, immIpowerOf2 mask) %{
predicate(UseZbs);
match(Set dst (Conv2B (AndI src mask)));
ins_cost(ALU_COST);

format %{ "bexti $dst, $src, $mask\t#@convI2Bool_andI_reg_immIpowerOf2" %}
ins_encode %{
__ bexti($dst$$Register, $src$$Register, exact_log2((juint)($mask$$constant)));
%}

ins_pipe(ialu_reg_reg);
%}

0 comments on commit b9d856f

Please sign in to comment.