Commit cfcc019a authored by alph's avatar alph Committed by Commit bot

[x64] Implemennt vroundsd AVX instruction.

BUG=v8:4406
LOG=N

Review URL: https://codereview.chromium.org/1420653005

Cr-Commit-Position: refs/heads/master@{#31493}
parent 4fe366f1
......@@ -910,7 +910,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
CpuFeatureScope sse_scope(masm(), SSE4_1);
RoundingMode const mode =
static_cast<RoundingMode>(MiscField::decode(instr->opcode()));
__ roundsd(i.OutputDoubleRegister(), i.InputDoubleRegister(0), mode);
__ Roundsd(i.OutputDoubleRegister(), i.InputDoubleRegister(0), mode);
break;
}
case kSSEFloat64ToFloat32:
......
......@@ -3596,7 +3596,7 @@ void LCodeGen::DoMathFloor(LMathFloor* instr) {
__ subq(output_reg, Immediate(1));
DeoptimizeIf(overflow, instr, Deoptimizer::kMinusZero);
}
__ roundsd(xmm_scratch, input_reg, kRoundDown);
__ Roundsd(xmm_scratch, input_reg, kRoundDown);
__ Cvttsd2si(output_reg, xmm_scratch);
__ cmpl(output_reg, Immediate(0x1));
DeoptimizeIf(overflow, instr, Deoptimizer::kOverflow);
......
......@@ -3420,6 +3420,7 @@ void Assembler::cmpltsd(XMMRegister dst, XMMRegister src) {
void Assembler::roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode) {
DCHECK(!IsEnabled(AVX));
DCHECK(IsEnabled(SSE4_1));
EnsureSpace ensure_space(this);
emit(0x66);
......@@ -3428,7 +3429,7 @@ void Assembler::roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode) {
emit(0x3a);
emit(0x0b);
emit_sse_operand(dst, src);
// Mask precision exeption.
// Mask precision exception.
emit(static_cast<byte>(mode) | 0x8);
}
......
......@@ -1381,6 +1381,11 @@ class Assembler : public AssemblerBase {
void vucomisd(XMMRegister dst, const Operand& src) {
vsd(0x2e, dst, xmm0, src, k66, k0F, kWIG);
}
void vroundsd(XMMRegister dst, XMMRegister src1, XMMRegister src2,
RoundingMode mode) {
vsd(0x0b, dst, src1, src2, k66, k0F3A, kWIG);
emit(static_cast<byte>(mode) | 0x8); // Mask precision exception.
}
void vsd(byte op, XMMRegister dst, XMMRegister src1, XMMRegister src2) {
vsd(op, dst, src1, src2, kF2, k0F, kWIG);
......
......@@ -952,6 +952,19 @@ int DisassemblerX64::AVXInstruction(byte* data) {
default:
UnimplementedInstruction();
}
} else if (vex_66() && vex_0f3a()) {
int mod, regop, rm, vvvv = vex_vreg();
get_modrm(*current, &mod, &regop, &rm);
switch (opcode) {
case 0x0b:
AppendToBuffer("vroundsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
default:
UnimplementedInstruction();
}
} else if (vex_f3() && vex_0f()) {
int mod, regop, rm, vvvv = vex_vreg();
get_modrm(*current, &mod, &regop, &rm);
......@@ -1493,7 +1506,7 @@ int DisassemblerX64::TwoByteOpcodeInstruction(byte* data) {
// roundsd xmm, xmm/m64, imm8
AppendToBuffer("roundsd %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer(",%d", (*current) & 3);
AppendToBuffer(",0x%x", (*current) & 3);
current += 1;
} else if (third_byte == 0x16) {
get_modrm(*current, &mod, &rm, &regop);
......
......@@ -2669,6 +2669,17 @@ void MacroAssembler::Movmskpd(Register dst, XMMRegister src) {
}
void MacroAssembler::Roundsd(XMMRegister dst, XMMRegister src,
RoundingMode mode) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vroundsd(dst, dst, src, mode);
} else {
roundsd(dst, src, mode);
}
}
void MacroAssembler::Sqrtsd(XMMRegister dst, XMMRegister src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
......
......@@ -921,6 +921,7 @@ class MacroAssembler: public Assembler {
void Movapd(XMMRegister dst, XMMRegister src);
void Movmskpd(Register dst, XMMRegister src);
void Roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode);
void Sqrtsd(XMMRegister dst, XMMRegister src);
void Sqrtsd(XMMRegister dst, const Operand& src);
......
......@@ -1484,6 +1484,16 @@ TEST(AssemblerX64AVX_sd) {
__ cmpq(rcx, rdx);
__ j(not_equal, &exit);
// Test vroundsd
__ movl(rax, Immediate(16));
__ movq(rdx, V8_UINT64_C(0x4002000000000000)); // 2.25
__ vmovq(xmm4, rdx);
__ vroundsd(xmm5, xmm4, xmm4, kRoundUp);
__ movq(rcx, V8_UINT64_C(0x4008000000000000)); // 3.0
__ vmovq(xmm6, rcx);
__ vucomisd(xmm5, xmm6);
__ j(not_equal, &exit);
__ movl(rdx, Immediate(6));
__ vcvtlsi2sd(xmm6, xmm6, rdx);
__ movl(Operand(rsp, 0), Immediate(5));
......
......@@ -540,6 +540,7 @@ TEST(DisasmX64) {
__ vminsd(xmm9, xmm1, Operand(rbx, rcx, times_8, 10000));
__ vmaxsd(xmm8, xmm1, xmm2);
__ vmaxsd(xmm9, xmm1, Operand(rbx, rcx, times_1, 10000));
__ vroundsd(xmm8, xmm3, xmm0, kRoundDown);
__ vsqrtsd(xmm8, xmm1, xmm2);
__ vsqrtsd(xmm9, xmm1, Operand(rbx, rcx, times_1, 10000));
__ vucomisd(xmm9, xmm1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment