Skip to content

Commit 3d3b782

Browse files
author
Hamlin Li
committed
8352607: RISC-V: use cmove in min/max when Zicond is supported
Reviewed-by: fyang, rehn
1 parent 9f582e5 commit 3d3b782

File tree

1 file changed

+18
-65
lines changed

1 file changed

+18
-65
lines changed

src/hotspot/cpu/riscv/riscv.ad

+18-65
Original file line numberDiff line numberDiff line change
@@ -9036,17 +9036,11 @@ instruct minI_reg_reg(iRegINoSp dst, iRegI src)
90369036
match(Set dst (MinI dst src));
90379037

90389038
ins_cost(BRANCH_COST + ALU_COST);
9039-
format %{
9040-
"ble $dst, $src, skip\t#@minI_reg_reg\n\t"
9041-
"mv $dst, $src\n\t"
9042-
"skip:"
9043-
%}
9039+
format %{"minI_reg_reg $dst, $dst, $src\t#@minI_reg_reg\n\t"%}
90449040

90459041
ins_encode %{
9046-
Label Lskip;
9047-
__ ble(as_Register($dst$$reg), as_Register($src$$reg), Lskip);
9048-
__ mv(as_Register($dst$$reg), as_Register($src$$reg));
9049-
__ bind(Lskip);
9042+
__ cmov_gt(as_Register($dst$$reg), as_Register($src$$reg),
9043+
as_Register($dst$$reg), as_Register($src$$reg));
90509044
%}
90519045

90529046
ins_pipe(pipe_class_compare);
@@ -9057,17 +9051,11 @@ instruct maxI_reg_reg(iRegINoSp dst, iRegI src)
90579051
match(Set dst (MaxI dst src));
90589052

90599053
ins_cost(BRANCH_COST + ALU_COST);
9060-
format %{
9061-
"bge $dst, $src, skip\t#@maxI_reg_reg\n\t"
9062-
"mv $dst, $src\n\t"
9063-
"skip:"
9064-
%}
9054+
format %{"maxI_reg_reg $dst, $dst, $src\t#@maxI_reg_reg\n\t"%}
90659055

90669056
ins_encode %{
9067-
Label Lskip;
9068-
__ bge(as_Register($dst$$reg), as_Register($src$$reg), Lskip);
9069-
__ mv(as_Register($dst$$reg), as_Register($src$$reg));
9070-
__ bind(Lskip);
9057+
__ cmov_lt(as_Register($dst$$reg), as_Register($src$$reg),
9058+
as_Register($dst$$reg), as_Register($src$$reg));
90719059
%}
90729060

90739061
ins_pipe(pipe_class_compare);
@@ -9083,17 +9071,11 @@ instruct minI_reg_zero(iRegINoSp dst, immI0 zero)
90839071
match(Set dst (MinI zero dst));
90849072

90859073
ins_cost(BRANCH_COST + ALU_COST);
9086-
format %{
9087-
"blez $dst, skip\t#@minI_reg_zero\n\t"
9088-
"mv $dst, zr\n\t"
9089-
"skip:"
9090-
%}
9074+
format %{"minI_reg_zero $dst, $dst, zr\t#@minI_reg_zero\n\t"%}
90919075

90929076
ins_encode %{
9093-
Label Lskip;
9094-
__ blez(as_Register($dst$$reg), Lskip);
9095-
__ mv(as_Register($dst$$reg), zr);
9096-
__ bind(Lskip);
9077+
__ cmov_gt(as_Register($dst$$reg), zr,
9078+
as_Register($dst$$reg), zr);
90979079
%}
90989080

90999081
ins_pipe(pipe_class_compare);
@@ -9105,17 +9087,11 @@ instruct maxI_reg_zero(iRegINoSp dst, immI0 zero)
91059087
match(Set dst (MaxI zero dst));
91069088

91079089
ins_cost(BRANCH_COST + ALU_COST);
9108-
format %{
9109-
"bgez $dst, skip\t#@maxI_reg_zero\n\t"
9110-
"mv $dst, zr\n\t"
9111-
"skip:"
9112-
%}
9090+
format %{"maxI_reg_zero $dst, $dst, zr\t#@maxI_reg_zero\n\t"%}
91139091

91149092
ins_encode %{
9115-
Label Lskip;
9116-
__ bgez(as_Register($dst$$reg), Lskip);
9117-
__ mv(as_Register($dst$$reg), zr);
9118-
__ bind(Lskip);
9093+
__ cmov_lt(as_Register($dst$$reg), zr,
9094+
as_Register($dst$$reg), zr);
91199095
%}
91209096

91219097
ins_pipe(pipe_class_compare);
@@ -9128,23 +9104,12 @@ instruct minI_rReg(iRegINoSp dst, iRegI src1, iRegI src2)
91289104
effect(DEF dst, USE src1, USE src2);
91299105

91309106
ins_cost(BRANCH_COST + ALU_COST * 2);
9131-
format %{
9132-
"ble $src1, $src2, Lsrc1\t#@minI_rReg\n\t"
9133-
"mv $dst, $src2\n\t"
9134-
"j Ldone\n\t"
9135-
"Lsrc1:\n\t"
9136-
"mv $dst, $src1\n\t"
9137-
"Ldone:"
9138-
%}
9107+
format %{"minI_rReg $dst, $src1, $src2\t#@minI_rReg\n\t"%}
91399108

91409109
ins_encode %{
9141-
Label Lsrc1, Ldone;
9142-
__ ble(as_Register($src1$$reg), as_Register($src2$$reg), Lsrc1);
9143-
__ mv(as_Register($dst$$reg), as_Register($src2$$reg));
9144-
__ j(Ldone);
9145-
__ bind(Lsrc1);
91469110
__ mv(as_Register($dst$$reg), as_Register($src1$$reg));
9147-
__ bind(Ldone);
9111+
__ cmov_gt(as_Register($src1$$reg), as_Register($src2$$reg),
9112+
as_Register($dst$$reg), as_Register($src2$$reg));
91489113
%}
91499114

91509115
ins_pipe(pipe_class_compare);
@@ -9157,24 +9122,12 @@ instruct maxI_rReg(iRegINoSp dst, iRegI src1, iRegI src2)
91579122
effect(DEF dst, USE src1, USE src2);
91589123

91599124
ins_cost(BRANCH_COST + ALU_COST * 2);
9160-
format %{
9161-
"bge $src1, $src2, Lsrc1\t#@maxI_rReg\n\t"
9162-
"mv $dst, $src2\n\t"
9163-
"j Ldone\n\t"
9164-
"Lsrc1:\n\t"
9165-
"mv $dst, $src1\n\t"
9166-
"Ldone:"
9167-
%}
9125+
format %{"maxI_rReg $dst, $src1, $src2\t#@maxI_rReg\n\t"%}
91689126

91699127
ins_encode %{
9170-
Label Lsrc1, Ldone;
9171-
__ bge(as_Register($src1$$reg), as_Register($src2$$reg), Lsrc1);
9172-
__ mv(as_Register($dst$$reg), as_Register($src2$$reg));
9173-
__ j(Ldone);
9174-
__ bind(Lsrc1);
91759128
__ mv(as_Register($dst$$reg), as_Register($src1$$reg));
9176-
__ bind(Ldone);
9177-
9129+
__ cmov_lt(as_Register($src1$$reg), as_Register($src2$$reg),
9130+
as_Register($dst$$reg), as_Register($src2$$reg));
91789131
%}
91799132

91809133
ins_pipe(pipe_class_compare);

0 commit comments

Comments
 (0)