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

8265491: Math Signum optimization for x86 #3581

Closed
wants to merge 16 commits into from
@@ -1053,28 +1053,21 @@ void C2_MacroAssembler::signum_fp(int opcode, XMMRegister dst,

Label DONE_LABEL;

if (opcode == Op_SignumF){
if (opcode == Op_SignumF) {
assert(UseSSE > 0, "required");
ucomiss(dst, zero);
} else if (opcode == Op_SignumD){
jcc(Assembler::equal, DONE_LABEL); // handle special case +0.0/-0.0, if argument is +0.0/-0.0, return argument
jcc(Assembler::parity, DONE_LABEL); // handle special case NaN, if argument NaN, return NaN
movflt(dst, one);
jcc(Assembler::above, DONE_LABEL);
xorps(dst, ExternalAddress(StubRoutines::x86::vector_float_sign_flip()), scratch);
} else if (opcode == Op_SignumD) {
assert(UseSSE > 1, "required");
ucomisd(dst, zero);
}

jcc(Assembler::equal, DONE_LABEL); // handle special case +0.0/-0.0, if argument is +0.0/-0.0, return argument
jcc(Assembler::parity, DONE_LABEL); // handle special case NaN, if argument NaN, return NaN

if (opcode == Op_SignumF){
movflt(dst, one);
} else if (opcode == Op_SignumD){
jcc(Assembler::equal, DONE_LABEL); // handle special case +0.0/-0.0, if argument is +0.0/-0.0, return argument
jcc(Assembler::parity, DONE_LABEL); // handle special case NaN, if argument NaN, return NaN
movdbl(dst, one);
}

jcc(Assembler::above, DONE_LABEL);

if (opcode == Op_SignumF){
xorps(dst, ExternalAddress(StubRoutines::x86::vector_float_sign_flip()), scratch);
} else if (opcode == Op_SignumD){
jcc(Assembler::above, DONE_LABEL);
xorpd(dst, ExternalAddress(StubRoutines::x86::vector_double_sign_flip()), scratch);
}

@@ -5788,7 +5788,6 @@ instruct evminmaxFP_reg_eavx(vec dst, vec a, vec b, vec atmp, vec btmp, kReg ktm
// --------------------------------- Signum ---------------------------

instruct signumF_reg(regF dst, regF zero, regF one, rRegP scratch, rFlagsReg cr) %{
predicate(UseSSE>=1);
match(Set dst (SignumF dst (Binary zero one)));
effect(TEMP scratch, KILL cr);
format %{ "signumF $dst, $dst\t! using $scratch as TEMP" %}
@@ -5800,7 +5799,6 @@ instruct signumF_reg(regF dst, regF zero, regF one, rRegP scratch, rFlagsReg cr)
%}

instruct signumD_reg(regD dst, regD zero, regD one, rRegP scratch, rFlagsReg cr) %{
predicate(UseSSE>=2);
match(Set dst (SignumD dst (Binary zero one)));
effect(TEMP scratch, KILL cr);
format %{ "signumD $dst, $dst\t! using $scratch as TEMP" %}