Skip to content

Commit

Permalink
8334396: RISC-V: verify perf of ReverseBytesI/L
Browse files Browse the repository at this point in the history
Reviewed-by: fyang, rehn
  • Loading branch information
Hamlin Li committed Jun 20, 2024
1 parent c6f3bf4 commit 6420846
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
31 changes: 3 additions & 28 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1914,13 +1914,16 @@ bool Matcher::match_rule_supported(int opcode) {
case Op_PopCountL:
return UsePopCountInstruction;

case Op_ReverseBytesI:
case Op_ReverseBytesL:
case Op_RotateRight:
case Op_RotateLeft:
case Op_CountLeadingZerosI:
case Op_CountLeadingZerosL:
case Op_CountTrailingZerosI:
case Op_CountTrailingZerosL:
return UseZbb;

case Op_FmaF:
case Op_FmaD:
case Op_FmaVF:
Expand Down Expand Up @@ -7856,34 +7859,6 @@ instruct xorL_reg_imm(iRegLNoSp dst, iRegL src1, immLAdd src2) %{
// ============================================================================
// BSWAP Instructions

instruct bytes_reverse_int(iRegINoSp dst, iRegIorL2I src, rFlagsReg cr) %{
match(Set dst (ReverseBytesI src));
effect(KILL cr);

ins_cost(ALU_COST * 13);
format %{ "revb_w_w $dst, $src\t#@bytes_reverse_int" %}

ins_encode %{
__ revb_w_w(as_Register($dst$$reg), as_Register($src$$reg));
%}

ins_pipe(pipe_class_default);
%}

instruct bytes_reverse_long(iRegLNoSp dst, iRegL src, rFlagsReg cr) %{
match(Set dst (ReverseBytesL src));
effect(KILL cr);

ins_cost(ALU_COST * 29);
format %{ "revb $dst, $src\t#@bytes_reverse_long" %}

ins_encode %{
__ revb(as_Register($dst$$reg), as_Register($src$$reg));
%}

ins_pipe(pipe_class_default);
%}

instruct bytes_reverse_unsigned_short(iRegINoSp dst, iRegIorL2I src) %{
match(Set dst (ReverseBytesUS src));

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/riscv/riscv_b.ad
Original file line number Diff line number Diff line change
Expand Up @@ -178,27 +178,27 @@ instruct convI2UL_reg_reg_b(iRegLNoSp dst, iRegIorL2I src, immL_32bits mask) %{

// BSWAP instructions
instruct bytes_reverse_int_b(iRegINoSp dst, iRegIorL2I src) %{
predicate(UseZbb);
match(Set dst (ReverseBytesI src));

ins_cost(ALU_COST * 2);
format %{ "revb_w_w $dst, $src\t#@bytes_reverse_int_b" %}

ins_encode %{
assert(UseZbb, "must be");
__ revb_w_w(as_Register($dst$$reg), as_Register($src$$reg));
%}

ins_pipe(ialu_reg);
%}

instruct bytes_reverse_long_b(iRegLNoSp dst, iRegL src) %{
predicate(UseZbb);
match(Set dst (ReverseBytesL src));

ins_cost(ALU_COST);
format %{ "rev8 $dst, $src\t#@bytes_reverse_long_b" %}

ins_encode %{
assert(UseZbb, "must be");
__ rev8(as_Register($dst$$reg), as_Register($src$$reg));
%}

Expand Down

0 comments on commit 6420846

Please sign in to comment.