Commit 9131cf7e authored by alph's avatar alph Committed by Commit bot

[x64] Emit vcvtss2sd & vcvtsd2ss when AVX is enabled.

BUG=v8:4406
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#31349}
parent 0138b265
...@@ -826,7 +826,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -826,7 +826,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
ASSEMBLE_SSE_BINOP(minss); ASSEMBLE_SSE_BINOP(minss);
break; break;
case kSSEFloat32ToFloat64: case kSSEFloat32ToFloat64:
ASSEMBLE_SSE_UNOP(cvtss2sd); ASSEMBLE_SSE_UNOP(Cvtss2sd);
break; break;
case kSSEFloat64Cmp: case kSSEFloat64Cmp:
ASSEMBLE_SSE_BINOP(ucomisd); ASSEMBLE_SSE_BINOP(ucomisd);
...@@ -909,7 +909,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -909,7 +909,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
break; break;
} }
case kSSEFloat64ToFloat32: case kSSEFloat64ToFloat32:
ASSEMBLE_SSE_UNOP(cvtsd2ss); ASSEMBLE_SSE_UNOP(Cvtsd2ss);
break; break;
case kSSEFloat64ToInt32: case kSSEFloat64ToInt32:
if (instr->InputAt(0)->IsDoubleRegister()) { if (instr->InputAt(0)->IsDoubleRegister()) {
......
...@@ -3131,6 +3131,7 @@ void Assembler::cvtqsi2sd(XMMRegister dst, Register src) { ...@@ -3131,6 +3131,7 @@ void Assembler::cvtqsi2sd(XMMRegister dst, Register src) {
void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) { void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) {
DCHECK(!IsEnabled(AVX));
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
emit(0xF3); emit(0xF3);
emit_optional_rex_32(dst, src); emit_optional_rex_32(dst, src);
...@@ -3141,6 +3142,7 @@ void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) { ...@@ -3141,6 +3142,7 @@ void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) {
void Assembler::cvtss2sd(XMMRegister dst, const Operand& src) { void Assembler::cvtss2sd(XMMRegister dst, const Operand& src) {
DCHECK(!IsEnabled(AVX));
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
emit(0xF3); emit(0xF3);
emit_optional_rex_32(dst, src); emit_optional_rex_32(dst, src);
...@@ -3151,6 +3153,7 @@ void Assembler::cvtss2sd(XMMRegister dst, const Operand& src) { ...@@ -3151,6 +3153,7 @@ void Assembler::cvtss2sd(XMMRegister dst, const Operand& src) {
void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) { void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) {
DCHECK(!IsEnabled(AVX));
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
emit(0xF2); emit(0xF2);
emit_optional_rex_32(dst, src); emit_optional_rex_32(dst, src);
...@@ -3161,6 +3164,7 @@ void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) { ...@@ -3161,6 +3164,7 @@ void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) {
void Assembler::cvtsd2ss(XMMRegister dst, const Operand& src) { void Assembler::cvtsd2ss(XMMRegister dst, const Operand& src) {
DCHECK(!IsEnabled(AVX));
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
emit(0xF2); emit(0xF2);
emit_optional_rex_32(dst, src); emit_optional_rex_32(dst, src);
......
...@@ -1325,6 +1325,18 @@ class Assembler : public AssemblerBase { ...@@ -1325,6 +1325,18 @@ class Assembler : public AssemblerBase {
void vminsd(XMMRegister dst, XMMRegister src1, const Operand& src2) { void vminsd(XMMRegister dst, XMMRegister src1, const Operand& src2) {
vsd(0x5d, dst, src1, src2); vsd(0x5d, dst, src1, src2);
} }
void vcvtss2sd(XMMRegister dst, XMMRegister src1, XMMRegister src2) {
vsd(0x5a, dst, src1, src2, kF3, k0F, kWIG);
}
void vcvtss2sd(XMMRegister dst, XMMRegister src1, const Operand& src2) {
vsd(0x5a, dst, src1, src2, kF3, k0F, kWIG);
}
void vcvtsd2ss(XMMRegister dst, XMMRegister src1, XMMRegister src2) {
vsd(0x5a, dst, src1, src2);
}
void vcvtsd2ss(XMMRegister dst, XMMRegister src1, const Operand& src2) {
vsd(0x5a, dst, src1, src2);
}
void vcvtlsi2sd(XMMRegister dst, XMMRegister src1, Register src2) { void vcvtlsi2sd(XMMRegister dst, XMMRegister src1, Register src2) {
XMMRegister isrc2 = {src2.code()}; XMMRegister isrc2 = {src2.code()};
vsd(0x2a, dst, src1, isrc2, kF2, k0F, kW0); vsd(0x2a, dst, src1, isrc2, kF2, k0F, kW0);
......
...@@ -966,6 +966,11 @@ int DisassemblerX64::AVXInstruction(byte* data) { ...@@ -966,6 +966,11 @@ int DisassemblerX64::AVXInstruction(byte* data) {
NameOfXMMRegister(vvvv)); NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current); current += PrintRightXMMOperand(current);
break; break;
case 0x5a:
AppendToBuffer("vcvtss2sd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
break;
case 0x5c: case 0x5c:
AppendToBuffer("vsubss %s,%s,", NameOfXMMRegister(regop), AppendToBuffer("vsubss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv)); NameOfXMMRegister(vvvv));
...@@ -1022,6 +1027,11 @@ int DisassemblerX64::AVXInstruction(byte* data) { ...@@ -1022,6 +1027,11 @@ int DisassemblerX64::AVXInstruction(byte* data) {
NameOfXMMRegister(vvvv)); NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current); current += PrintRightXMMOperand(current);
break; break;
case 0x5a:
AppendToBuffer("vcvtsd2ss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
break;
case 0x5c: case 0x5c:
AppendToBuffer("vsubsd %s,%s,", NameOfXMMRegister(regop), AppendToBuffer("vsubsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv)); NameOfXMMRegister(vvvv));
......
...@@ -2999,8 +2999,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { ...@@ -2999,8 +2999,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
if (elements_kind == FLOAT32_ELEMENTS) { if (elements_kind == FLOAT32_ELEMENTS) {
XMMRegister result(ToDoubleRegister(instr->result())); XMMRegister result(ToDoubleRegister(instr->result()));
__ movss(result, operand); __ Cvtss2sd(result, operand);
__ cvtss2sd(result, result);
} else if (elements_kind == FLOAT64_ELEMENTS) { } else if (elements_kind == FLOAT64_ELEMENTS) {
__ Movsd(ToDoubleRegister(instr->result()), operand); __ Movsd(ToDoubleRegister(instr->result()), operand);
} else { } else {
...@@ -3715,8 +3714,8 @@ void LCodeGen::DoMathRound(LMathRound* instr) { ...@@ -3715,8 +3714,8 @@ void LCodeGen::DoMathRound(LMathRound* instr) {
void LCodeGen::DoMathFround(LMathFround* instr) { void LCodeGen::DoMathFround(LMathFround* instr) {
XMMRegister input_reg = ToDoubleRegister(instr->value()); XMMRegister input_reg = ToDoubleRegister(instr->value());
XMMRegister output_reg = ToDoubleRegister(instr->result()); XMMRegister output_reg = ToDoubleRegister(instr->result());
__ cvtsd2ss(output_reg, input_reg); __ Cvtsd2ss(output_reg, input_reg);
__ cvtss2sd(output_reg, output_reg); __ Cvtss2sd(output_reg, output_reg);
} }
...@@ -4243,7 +4242,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { ...@@ -4243,7 +4242,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
if (elements_kind == FLOAT32_ELEMENTS) { if (elements_kind == FLOAT32_ELEMENTS) {
XMMRegister value(ToDoubleRegister(instr->value())); XMMRegister value(ToDoubleRegister(instr->value()));
__ cvtsd2ss(value, value); __ Cvtsd2ss(value, value);
__ movss(operand, value); __ movss(operand, value);
} else if (elements_kind == FLOAT64_ELEMENTS) { } else if (elements_kind == FLOAT64_ELEMENTS) {
__ Movsd(operand, ToDoubleRegister(instr->value())); __ Movsd(operand, ToDoubleRegister(instr->value()));
......
...@@ -787,6 +787,46 @@ void MacroAssembler::PopCallerSaved(SaveFPRegsMode fp_mode, ...@@ -787,6 +787,46 @@ void MacroAssembler::PopCallerSaved(SaveFPRegsMode fp_mode,
} }
void MacroAssembler::Cvtss2sd(XMMRegister dst, XMMRegister src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vcvtss2sd(dst, src, src);
} else {
cvtss2sd(dst, src);
}
}
void MacroAssembler::Cvtss2sd(XMMRegister dst, const Operand& src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vcvtss2sd(dst, dst, src);
} else {
cvtss2sd(dst, src);
}
}
void MacroAssembler::Cvtsd2ss(XMMRegister dst, XMMRegister src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vcvtsd2ss(dst, src, src);
} else {
cvtsd2ss(dst, src);
}
}
void MacroAssembler::Cvtsd2ss(XMMRegister dst, const Operand& src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vcvtsd2ss(dst, dst, src);
} else {
cvtsd2ss(dst, src);
}
}
void MacroAssembler::Cvtlsi2sd(XMMRegister dst, Register src) { void MacroAssembler::Cvtlsi2sd(XMMRegister dst, Register src) {
if (CpuFeatures::IsSupported(AVX)) { if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX); CpuFeatureScope scope(this, AVX);
......
...@@ -806,6 +806,11 @@ class MacroAssembler: public Assembler { ...@@ -806,6 +806,11 @@ class MacroAssembler: public Assembler {
void Set(Register dst, int64_t x); void Set(Register dst, int64_t x);
void Set(const Operand& dst, intptr_t x); void Set(const Operand& dst, intptr_t x);
void Cvtss2sd(XMMRegister dst, XMMRegister src);
void Cvtss2sd(XMMRegister dst, const Operand& src);
void Cvtsd2ss(XMMRegister dst, XMMRegister src);
void Cvtsd2ss(XMMRegister dst, const Operand& src);
// cvtsi2sd instruction only writes to the low 64-bit of dst register, which // cvtsi2sd instruction only writes to the low 64-bit of dst register, which
// hinders register renaming and makes dependence chains longer. So we use // hinders register renaming and makes dependence chains longer. So we use
// xorpd to clear the dst register before cvtsi2sd to solve this issue. // xorpd to clear the dst register before cvtsi2sd to solve this issue.
......
...@@ -1360,6 +1360,19 @@ TEST(AssemblerX64AVX_sd) { ...@@ -1360,6 +1360,19 @@ TEST(AssemblerX64AVX_sd) {
__ vmovsd(xmm6, xmm5); __ vmovsd(xmm6, xmm5);
__ vmovapd(xmm3, xmm6); __ vmovapd(xmm3, xmm6);
// Test vcvtss2sd & vcvtsd2ss
__ movl(rax, Immediate(9));
__ movq(rdx, V8_INT64_C(0x426D1A0000000000));
__ movq(Operand(rsp, 0), rdx);
__ vcvtsd2ss(xmm6, xmm6, Operand(rsp, 0));
__ vcvtss2sd(xmm7, xmm6, xmm6);
__ vcvtsd2ss(xmm8, xmm7, xmm7);
__ movss(Operand(rsp, 0), xmm8);
__ vcvtss2sd(xmm9, xmm8, Operand(rsp, 0));
__ vmovq(rcx, xmm9);
__ cmpq(rcx, rdx);
__ j(not_equal, &exit);
// Test vcvttsd2si // Test vcvttsd2si
__ movl(rax, Immediate(10)); __ movl(rax, Immediate(10));
__ movl(rdx, Immediate(123)); __ movl(rdx, Immediate(123));
......
...@@ -538,6 +538,10 @@ TEST(DisasmX64) { ...@@ -538,6 +538,10 @@ TEST(DisasmX64) {
__ vucomisd(xmm9, xmm1); __ vucomisd(xmm9, xmm1);
__ vucomisd(xmm8, Operand(rbx, rdx, times_2, 10981)); __ vucomisd(xmm8, Operand(rbx, rdx, times_2, 10981));
__ vcvtss2sd(xmm4, xmm9, xmm11);
__ vcvtsd2ss(xmm9, xmm3, xmm2);
__ vcvtss2sd(xmm4, xmm9, Operand(rbx, rcx, times_1, 10000));
__ vcvtsd2ss(xmm9, xmm3, Operand(rbx, rcx, times_1, 10000));
__ vcvtlsi2sd(xmm5, xmm9, rcx); __ vcvtlsi2sd(xmm5, xmm9, rcx);
__ vcvtlsi2sd(xmm9, xmm3, Operand(rbx, r9, times_4, 10000)); __ vcvtlsi2sd(xmm9, xmm3, Operand(rbx, r9, times_4, 10000));
__ vcvttsd2si(r9, xmm6); __ vcvttsd2si(r9, xmm6);
......
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