Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8283726: x86 intrinsics for compare method in Integer and Long #7975

Closed
wants to merge 6 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp
Original file line number Diff line number Diff line change
@@ -4463,3 +4463,54 @@ void C2_MacroAssembler::vector_maskall_operation32(KRegister dst, Register src,
kunpckdql(dst, tmp, tmp);
}
#endif

void C2_MacroAssembler::compare_signed_int(Register dst, Register op1, Register op2, Register tmp) {
Label done;
movl(tmp, -1);
cmpl(op1, op2);
jccb(Assembler::less, done);
movl(tmp, 1);
jccb(Assembler::greater, done);
movl(tmp, 0);
bind(done);
movl(dst, tmp);
}

void C2_MacroAssembler::compare_unsigned_int(Register dst, Register op1, Register op2, Register tmp) {
Label done;
movl(tmp, -1);
cmpl(op1, op2);
jccb(Assembler::below, done);
movl(tmp, 1);
jccb(Assembler::above, done);
movl(tmp, 0);
bind(done);
movl(dst, tmp);
}

#ifdef _LP64
void C2_MacroAssembler::compare_signed_long(Register dst, Register op1, Register op2, Register tmp) {
Label done;
movq(tmp, -1);
cmpq(op1, op2);
jccb(Assembler::less, done);
movq(tmp, 1);
jccb(Assembler::greater, done);
movq(tmp, 0);
bind(done);
movq(dst, tmp);
}

void C2_MacroAssembler::compare_unsigned_long(Register dst, Register op1, Register op2, Register tmp) {
Label done;
movq(tmp, -1);
cmpq(op1, op2);
jccb(Assembler::below, done);
movq(tmp, 1);
jccb(Assembler::above, done);
movq(tmp, 0);
bind(done);
movq(dst, tmp);
}
#endif

10 changes: 9 additions & 1 deletion src/hotspot/cpu/x86/c2_MacroAssembler_x86.hpp
Original file line number Diff line number Diff line change
@@ -324,4 +324,12 @@
XMMRegister xtmp2, XMMRegister xtmp3, Register rtmp,
int vec_enc);

#endif // CPU_X86_C2_MACROASSEMBLER_X86_HPP
void compare_signed_int(Register dst, Register op1, Register op2, Register tmp);
void compare_unsigned_int(Register dst, Register op1, Register op2, Register tmp);
#ifdef _LP64
void compare_signed_long(Register dst, Register op1, Register op2, Register tmp);
void compare_unsigned_long(Register dst, Register op1, Register op2, Register tmp);
#endif


#endif // CPU_X86_C2_MACROASSEMBLER_X86_HPP
64 changes: 4 additions & 60 deletions src/hotspot/cpu/x86/x86_64.ad
Original file line number Diff line number Diff line change
@@ -12109,21 +12109,7 @@ instruct compareSignedI_rReg(rRegI dst, rRegI op1, rRegI op2, rRegI tmp, rFlagsR

format %{ "cmpsignedl $op1, $op2 # CompareSignedI" %}
ins_encode %{
Register op1 = $op1$$Register;
Register op2 = $op2$$Register;
Register dest = $dst$$Register;
Register tmp = $tmp$$Register;

Label done;
__ movl(tmp, -1);
__ cmpl(op1, op2);
__ jccb(Assembler::less, done);
__ movl(tmp, 1);
__ jccb(Assembler::greater, done);
__ movl(tmp, 0);
__ bind(done);
__ movl(dest, tmp);

__ compare_signed_int($dst$$Register, $op1$$Register, $op2$$Register, $tmp$$Register);
%}
ins_pipe(ialu_cr_reg_reg);
%}
@@ -12135,21 +12121,7 @@ instruct compareSignedL_rReg(rRegI dst, rRegL op1, rRegL op2, rRegI tmp, rFlagsR

format %{ "cmpsignedq $op1, $op2 # CompareSignedL" %}
ins_encode %{
Register op1 = $op1$$Register;
Register op2 = $op2$$Register;
Register dest = $dst$$Register;
Register tmp = $tmp$$Register;

Label done;
__ movl(tmp, -1);
__ cmpq(op1, op2);
__ jccb(Assembler::less, done);
__ movl(tmp, 1);
__ jccb(Assembler::greater, done);
__ movl(tmp, 0);
__ bind(done);
__ movl(dest, tmp);

__ compare_signed_long($dst$$Register, $op1$$Register, $op2$$Register, $tmp$$Register);
%}
ins_pipe(ialu_cr_reg_reg);
%}
@@ -12162,21 +12134,7 @@ instruct compareUnsignedI_rReg(rRegI dst, rRegI op1, rRegI op2, rRegI tmp, rFlag

format %{ "cmpunsignedl $op1, $op2 # CompareUnsignedI" %}
ins_encode %{
Register op1 = $op1$$Register;
Register op2 = $op2$$Register;
Register dest = $dst$$Register;
Register tmp = $tmp$$Register;

Label done;
__ movl(tmp, -1);
__ cmpl(op1, op2);
__ jccb(Assembler::below, done);
__ movl(tmp, 1);
__ jccb(Assembler::above, done);
__ movl(tmp, 0);
__ bind(done);
__ movl(dest, tmp);

__ compare_unsigned_int($dst$$Register, $op1$$Register, $op2$$Register, $tmp$$Register);
%}
ins_pipe(ialu_cr_reg_reg);
%}
@@ -12188,21 +12146,7 @@ instruct compareUnsignedL_rReg(rRegI dst, rRegL op1, rRegL op2, rRegI tmp, rFlag

format %{ "cmpunsignedq $op1, $op2 # CompareUnsignedL" %}
ins_encode %{
Register op1 = $op1$$Register;
Register op2 = $op2$$Register;
Register dest = $dst$$Register;
Register tmp = $tmp$$Register;

Label done;
__ movl(tmp, -1);
__ cmpq(op1, op2);
__ jccb(Assembler::below, done);
__ movl(tmp, 1);
__ jccb(Assembler::above, done);
__ movl(tmp, 0);
__ bind(done);
__ movl(dest, tmp);

__ compare_unsigned_long($dst$$Register, $op1$$Register, $op2$$Register, $tmp$$Register);
%}
ins_pipe(ialu_cr_reg_reg);
%}