Skip to content

Commit 0995b94

Browse files
Anjian-WenRealFYang
authored andcommitted
8354815: RISC-V: Change type of bitwise rotation shift to iRegIorL2I
Reviewed-by: fyang, fjiang
1 parent 38f138b commit 0995b94

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/hotspot/cpu/riscv/riscv.ad

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6445,7 +6445,6 @@ instruct addI_reg_imm(iRegINoSp dst, iRegIorL2I src1, immIAdd src2) %{
64456445
format %{ "addiw $dst, $src1, $src2\t#@addI_reg_imm" %}
64466446

64476447
ins_encode %{
6448-
int32_t con = (int32_t)$src2$$constant;
64496448
__ addiw(as_Register($dst$$reg),
64506449
as_Register($src1$$reg),
64516450
$src2$$constant);
@@ -6507,7 +6506,6 @@ instruct addP_reg_imm(iRegPNoSp dst, iRegP src1, immLAdd src2) %{
65076506
format %{ "addi $dst, $src1, $src2\t# ptr, #@addP_reg_imm" %}
65086507

65096508
ins_encode %{
6510-
// src2 is imm, so actually call the addi
65116509
__ addi(as_Register($dst$$reg),
65126510
as_Register($src1$$reg),
65136511
$src2$$constant);
@@ -6829,7 +6827,7 @@ instruct UmodL(iRegLNoSp dst, iRegL src1, iRegL src2) %{
68296827
// Integer Shifts
68306828

68316829
// Shift Left Register
6832-
// In RV64I, only the low 5 bits of src2 are considered for the shift amount
6830+
// Only the low 5 bits of src2 are considered for the shift amount, all other bits are ignored.
68336831
instruct lShiftI_reg_reg(iRegINoSp dst, iRegIorL2I src1, iRegIorL2I src2) %{
68346832
match(Set dst (LShiftI src1 src2));
68356833
ins_cost(ALU_COST);
@@ -6862,7 +6860,7 @@ instruct lShiftI_reg_imm(iRegINoSp dst, iRegIorL2I src1, immI src2) %{
68626860
%}
68636861

68646862
// Shift Right Logical Register
6865-
// In RV64I, only the low 5 bits of src2 are considered for the shift amount
6863+
// Only the low 5 bits of src2 are considered for the shift amount, all other bits are ignored.
68666864
instruct urShiftI_reg_reg(iRegINoSp dst, iRegIorL2I src1, iRegIorL2I src2) %{
68676865
match(Set dst (URShiftI src1 src2));
68686866
ins_cost(ALU_COST);
@@ -6895,7 +6893,7 @@ instruct urShiftI_reg_imm(iRegINoSp dst, iRegIorL2I src1, immI src2) %{
68956893
%}
68966894

68976895
// Shift Right Arithmetic Register
6898-
// In RV64I, only the low 5 bits of src2 are considered for the shift amount
6896+
// Only the low 5 bits of src2 are considered for the shift amount, all other bits are ignored.
68996897
instruct rShiftI_reg_reg(iRegINoSp dst, iRegIorL2I src1, iRegIorL2I src2) %{
69006898
match(Set dst (RShiftI src1 src2));
69016899
ins_cost(ALU_COST);
@@ -6930,7 +6928,7 @@ instruct rShiftI_reg_imm(iRegINoSp dst, iRegIorL2I src1, immI src2) %{
69306928
// Long Shifts
69316929

69326930
// Shift Left Register
6933-
// In RV64I, only the low 6 bits of src2 are considered for the shift amount
6931+
// Only the low 6 bits of src2 are considered for the shift amount, all other bits are ignored.
69346932
instruct lShiftL_reg_reg(iRegLNoSp dst, iRegL src1, iRegIorL2I src2) %{
69356933
match(Set dst (LShiftL src1 src2));
69366934

@@ -6965,7 +6963,7 @@ instruct lShiftL_reg_imm(iRegLNoSp dst, iRegL src1, immI src2) %{
69656963
%}
69666964

69676965
// Shift Right Logical Register
6968-
// In RV64I, only the low 6 bits of src2 are considered for the shift amount
6966+
// Only the low 6 bits of src2 are considered for the shift amount, all other bits are ignored.
69696967
instruct urShiftL_reg_reg(iRegLNoSp dst, iRegL src1, iRegIorL2I src2) %{
69706968
match(Set dst (URShiftL src1 src2));
69716969

@@ -7018,7 +7016,7 @@ instruct urShiftP_reg_imm(iRegLNoSp dst, iRegP src1, immI src2) %{
70187016
%}
70197017

70207018
// Shift Right Arithmetic Register
7021-
// In RV64I, only the low 6 bits of src2 are considered for the shift amount
7019+
// Only the low 6 bits of src2 are considered for the shift amount, all other bits are ignored.
70227020
instruct rShiftL_reg_reg(iRegLNoSp dst, iRegL src1, iRegIorL2I src2) %{
70237021
match(Set dst (RShiftL src1 src2));
70247022

src/hotspot/cpu/riscv/riscv_b.ad

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626
// RISCV Bit-Manipulation Extension Architecture Description File
2727

28-
instruct rorI_imm_b(iRegINoSp dst, iRegI src, immI shift) %{
28+
// Rotate Right Word Immediate
29+
instruct rorI_imm_b(iRegINoSp dst, iRegIorL2I src, immI shift) %{
2930
predicate(UseZbb);
3031
match(Set dst (RotateRight src shift));
3132

@@ -39,6 +40,7 @@ instruct rorI_imm_b(iRegINoSp dst, iRegI src, immI shift) %{
3940
ins_pipe(ialu_reg_shift);
4041
%}
4142

43+
// Rotate Right Immediate
4244
instruct rorL_imm_b(iRegLNoSp dst, iRegL src, immI shift) %{
4345
predicate(UseZbb);
4446
match(Set dst (RotateRight src shift));
@@ -53,7 +55,9 @@ instruct rorL_imm_b(iRegLNoSp dst, iRegL src, immI shift) %{
5355
ins_pipe(ialu_reg_shift);
5456
%}
5557

56-
instruct rorI_reg_b(iRegINoSp dst, iRegI src, iRegI shift) %{
58+
// Rotate Right Word Register
59+
// Only the low 5 bits of shift value are used, all other bits are ignored.
60+
instruct rorI_reg_b(iRegINoSp dst, iRegIorL2I src, iRegIorL2I shift) %{
5761
predicate(UseZbb);
5862
match(Set dst (RotateRight src shift));
5963

@@ -65,7 +69,9 @@ instruct rorI_reg_b(iRegINoSp dst, iRegI src, iRegI shift) %{
6569
ins_pipe(ialu_reg_reg);
6670
%}
6771

68-
instruct rorL_reg_b(iRegLNoSp dst, iRegL src, iRegI shift) %{
72+
// Rotate Right Register
73+
// Only the low 6 bits of shift value are used, all other bits are ignored.
74+
instruct rorL_reg_b(iRegLNoSp dst, iRegL src, iRegIorL2I shift) %{
6975
predicate(UseZbb);
7076
match(Set dst (RotateRight src shift));
7177

@@ -77,7 +83,9 @@ instruct rorL_reg_b(iRegLNoSp dst, iRegL src, iRegI shift) %{
7783
ins_pipe(ialu_reg_reg);
7884
%}
7985

80-
instruct rolI_reg_b(iRegINoSp dst, iRegI src, iRegI shift) %{
86+
// Rotate Left Word Register
87+
// Only the low 5 bits of shift value are used, all other bits are ignored.
88+
instruct rolI_reg_b(iRegINoSp dst, iRegIorL2I src, iRegIorL2I shift) %{
8189
predicate(UseZbb);
8290
match(Set dst (RotateLeft src shift));
8391

@@ -89,7 +97,9 @@ instruct rolI_reg_b(iRegINoSp dst, iRegI src, iRegI shift) %{
8997
ins_pipe(ialu_reg_reg);
9098
%}
9199

92-
instruct rolL_reg_b(iRegLNoSp dst, iRegL src, iRegI shift) %{
100+
// Rotate Left Register
101+
// Only the low 6 bits of shift value are used, all other bits are ignored.
102+
instruct rolL_reg_b(iRegLNoSp dst, iRegL src, iRegIorL2I shift) %{
93103
predicate(UseZbb);
94104
match(Set dst (RotateLeft src shift));
95105

src/hotspot/cpu/riscv/riscv_v.ad

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3499,6 +3499,7 @@ instruct vrotate_right(vReg dst, vReg src, vReg shift) %{
34993499
ins_pipe(pipe_slow);
35003500
%}
35013501

3502+
// Only the low log2(SEW) bits of shift value are used, all other bits are ignored.
35023503
instruct vrotate_right_reg(vReg dst, vReg src, iRegIorL2I shift) %{
35033504
match(Set dst (RotateRightV src (Replicate shift)));
35043505
format %{ "vrotate_right_reg $dst, $src, $shift\t" %}
@@ -3541,6 +3542,7 @@ instruct vrotate_right_masked(vReg dst_src, vReg shift, vRegMask_V0 v0) %{
35413542
ins_pipe(pipe_slow);
35423543
%}
35433544

3545+
// Only the low log2(SEW) bits of shift value are used, all other bits are ignored.
35443546
instruct vrotate_right_reg_masked(vReg dst_src, iRegIorL2I shift, vRegMask_V0 v0) %{
35453547
match(Set dst_src (RotateRightV (Binary dst_src (Replicate shift)) v0));
35463548
format %{ "vrotate_right_reg_masked $dst_src, $dst_src, $shift, v0.t\t" %}
@@ -3584,6 +3586,7 @@ instruct vrotate_left(vReg dst, vReg src, vReg shift) %{
35843586
ins_pipe(pipe_slow);
35853587
%}
35863588

3589+
// Only the low log2(SEW) bits of shift value are used, all other bits are ignored.
35873590
instruct vrotate_left_reg(vReg dst, vReg src, iRegIorL2I shift) %{
35883591
match(Set dst (RotateLeftV src (Replicate shift)));
35893592
format %{ "vrotate_left_reg $dst, $src, $shift\t" %}
@@ -3627,6 +3630,7 @@ instruct vrotate_left_masked(vReg dst_src, vReg shift, vRegMask_V0 v0) %{
36273630
ins_pipe(pipe_slow);
36283631
%}
36293632

3633+
// Only the low log2(SEW) bits of shift value are used, all other bits are ignored.
36303634
instruct vrotate_left_reg_masked(vReg dst_src, iRegIorL2I shift, vRegMask_V0 v0) %{
36313635
match(Set dst_src (RotateLeftV (Binary dst_src (Replicate shift)) v0));
36323636
format %{ "vrotate_left_reg_masked $dst_src, $dst_src, $shift, v0.t\t" %}

0 commit comments

Comments
 (0)