[x64] Make use of vxorpd when AVX is enabled.

BUG=v8:4406
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#31323}
This commit is contained in:
alph 2015-10-15 23:15:44 -07:00 committed by Commit bot
parent 5d9c7ab648
commit 3539808150
7 changed files with 40 additions and 25 deletions

View File

@ -2449,6 +2449,7 @@ void Assembler::orps(XMMRegister dst, const Operand& src) {
void Assembler::xorps(XMMRegister dst, XMMRegister src) {
DCHECK(!IsEnabled(AVX));
EnsureSpace ensure_space(this);
emit_optional_rex_32(dst, src);
emit(0x0F);
@ -2458,6 +2459,7 @@ void Assembler::xorps(XMMRegister dst, XMMRegister src) {
void Assembler::xorps(XMMRegister dst, const Operand& src) {
DCHECK(!IsEnabled(AVX));
EnsureSpace ensure_space(this);
emit_optional_rex_32(dst, src);
emit(0x0F);
@ -3323,6 +3325,7 @@ void Assembler::orpd(XMMRegister dst, XMMRegister src) {
void Assembler::xorpd(XMMRegister dst, XMMRegister src) {
DCHECK(!IsEnabled(AVX));
EnsureSpace ensure_space(this);
emit(0x66);
emit_optional_rex_32(dst, src);

View File

@ -355,13 +355,13 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ j(carry, &continue_sqrt, Label::kNear);
// Set result to Infinity in the special case.
__ xorps(double_result, double_result);
__ Xorpd(double_result, double_result);
__ subsd(double_result, double_scratch);
__ jmp(&done);
__ bind(&continue_sqrt);
// sqrtsd returns -0 when input is -0. ECMA spec requires +0.
__ xorps(double_scratch, double_scratch);
__ Xorpd(double_scratch, double_scratch);
__ addsd(double_scratch, double_base); // Convert -0 to 0.
__ sqrtsd(double_result, double_scratch);
__ jmp(&done);
@ -387,12 +387,12 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ j(carry, &continue_rsqrt, Label::kNear);
// Set result to 0 in the special case.
__ xorps(double_result, double_result);
__ Xorpd(double_result, double_result);
__ jmp(&done);
__ bind(&continue_rsqrt);
// sqrtsd returns -0 when input is -0. ECMA spec requires +0.
__ xorps(double_exponent, double_exponent);
__ Xorpd(double_exponent, double_exponent);
__ addsd(double_exponent, double_base); // Convert -0 to +0.
__ sqrtsd(double_exponent, double_exponent);
__ divsd(double_result, double_exponent);
@ -478,7 +478,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ Movsd(double_result, double_scratch2);
// Test whether result is zero. Bail out to check for subnormal result.
// Due to subnormals, x^-y == (1/x)^y does not hold in all cases.
__ xorps(double_scratch2, double_scratch2);
__ Xorpd(double_scratch2, double_scratch2);
__ ucomisd(double_scratch2, double_result);
// double_exponent aliased as double_scratch2 has already been overwritten
// and may not have contained the exponent value in the first place when the

View File

@ -604,7 +604,7 @@ void MathExpGenerator::EmitMathExp(MacroAssembler* masm,
__ Move(kScratchRegister, ExternalReference::math_exp_constants(0));
__ Movsd(double_scratch, Operand(kScratchRegister, 0 * kDoubleSize));
__ xorpd(result, result);
__ Xorpd(result, result);
__ ucomisd(double_scratch, input);
__ j(above_equal, &done);
__ ucomisd(input, Operand(kScratchRegister, 1 * kDoubleSize));

View File

@ -1975,7 +1975,7 @@ void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
__ bind(&check_zero);
XMMRegister xmm_scratch = double_scratch0();
__ xorps(xmm_scratch, xmm_scratch);
__ Xorpd(xmm_scratch, xmm_scratch);
__ ucomisd(left_reg, xmm_scratch);
__ j(not_equal, &return_left, Label::kNear); // left == right != 0.
// At this point, both left and right are either 0 or -0.
@ -2128,7 +2128,7 @@ void LCodeGen::DoBranch(LBranch* instr) {
DCHECK(!info()->IsStub());
XMMRegister reg = ToDoubleRegister(instr->value());
XMMRegister xmm_scratch = double_scratch0();
__ xorps(xmm_scratch, xmm_scratch);
__ Xorpd(xmm_scratch, xmm_scratch);
__ ucomisd(reg, xmm_scratch);
EmitBranch(instr, not_equal);
} else {
@ -2149,7 +2149,7 @@ void LCodeGen::DoBranch(LBranch* instr) {
} else if (type.IsHeapNumber()) {
DCHECK(!info()->IsStub());
XMMRegister xmm_scratch = double_scratch0();
__ xorps(xmm_scratch, xmm_scratch);
__ Xorpd(xmm_scratch, xmm_scratch);
__ ucomisd(xmm_scratch, FieldOperand(reg, HeapNumber::kValueOffset));
EmitBranch(instr, not_equal);
} else if (type.IsString()) {
@ -2238,7 +2238,7 @@ void LCodeGen::DoBranch(LBranch* instr) {
__ CompareRoot(map, Heap::kHeapNumberMapRootIndex);
__ j(not_equal, &not_heap_number, Label::kNear);
XMMRegister xmm_scratch = double_scratch0();
__ xorps(xmm_scratch, xmm_scratch);
__ Xorpd(xmm_scratch, xmm_scratch);
__ ucomisd(xmm_scratch, FieldOperand(reg, HeapNumber::kValueOffset));
__ j(zero, instr->FalseLabel(chunk_));
__ jmp(instr->TrueLabel(chunk_));
@ -2407,7 +2407,7 @@ void LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) {
if (rep.IsDouble()) {
XMMRegister value = ToDoubleRegister(instr->value());
XMMRegister xmm_scratch = double_scratch0();
__ xorps(xmm_scratch, xmm_scratch);
__ Xorpd(xmm_scratch, xmm_scratch);
__ ucomisd(xmm_scratch, value);
EmitFalseBranch(instr, not_equal);
__ movmskpd(kScratchRegister, value);
@ -3576,7 +3576,7 @@ void LCodeGen::DoMathAbs(LMathAbs* instr) {
if (r.IsDouble()) {
XMMRegister scratch = double_scratch0();
XMMRegister input_reg = ToDoubleRegister(instr->value());
__ xorps(scratch, scratch);
__ Xorpd(scratch, scratch);
__ subsd(scratch, input_reg);
__ andps(input_reg, scratch);
} else if (r.IsInteger32()) {
@ -3615,7 +3615,7 @@ void LCodeGen::DoMathFloor(LMathFloor* instr) {
} else {
Label negative_sign, done;
// Deoptimize on unordered.
__ xorps(xmm_scratch, xmm_scratch); // Zero the register.
__ Xorpd(xmm_scratch, xmm_scratch); // Zero the register.
__ ucomisd(input_reg, xmm_scratch);
DeoptimizeIf(parity_even, instr, Deoptimizer::kNaN);
__ j(below, &negative_sign, Label::kNear);
@ -3751,13 +3751,13 @@ void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
__ j(not_equal, &sqrt, Label::kNear);
__ j(carry, &sqrt, Label::kNear);
// If input is -Infinity, return Infinity.
__ xorps(input_reg, input_reg);
__ Xorpd(input_reg, input_reg);
__ subsd(input_reg, xmm_scratch);
__ jmp(&done, Label::kNear);
// Square root.
__ bind(&sqrt);
__ xorps(xmm_scratch, xmm_scratch);
__ Xorpd(xmm_scratch, xmm_scratch);
__ addsd(input_reg, xmm_scratch); // Convert -0 to +0.
__ sqrtsd(input_reg, input_reg);
__ bind(&done);
@ -3815,7 +3815,7 @@ void LCodeGen::DoMathLog(LMathLog* instr) {
XMMRegister input_reg = ToDoubleRegister(instr->value());
XMMRegister xmm_scratch = double_scratch0();
Label positive, done, zero;
__ xorps(xmm_scratch, xmm_scratch);
__ Xorpd(xmm_scratch, xmm_scratch);
__ ucomisd(input_reg, xmm_scratch);
__ j(above, &positive, Label::kNear);
__ j(not_carry, &zero, Label::kNear);
@ -4293,7 +4293,7 @@ void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) {
if (instr->NeedsCanonicalization()) {
XMMRegister xmm_scratch = double_scratch0();
// Turn potential sNaN value into qNaN.
__ xorps(xmm_scratch, xmm_scratch);
__ Xorpd(xmm_scratch, xmm_scratch);
__ subsd(value, xmm_scratch);
}
@ -4924,7 +4924,7 @@ void LCodeGen::EmitNumberUntagD(LNumberUntagD* instr, Register input_reg,
if (deoptimize_on_minus_zero) {
XMMRegister xmm_scratch = double_scratch0();
__ xorps(xmm_scratch, xmm_scratch);
__ Xorpd(xmm_scratch, xmm_scratch);
__ ucomisd(xmm_scratch, result_reg);
__ j(not_equal, &done, Label::kNear);
__ movmskpd(kScratchRegister, result_reg);

View File

@ -189,7 +189,7 @@ void LGapResolver::EmitMove(int index) {
uint64_t int_val = bit_cast<uint64_t, double>(v);
XMMRegister dst = cgen_->ToDoubleRegister(destination);
if (int_val == 0) {
__ xorps(dst, dst);
__ Xorpd(dst, dst);
} else {
__ Set(kScratchRegister, int_val);
__ Movq(dst, kScratchRegister);

View File

@ -793,7 +793,7 @@ void MacroAssembler::Cvtlsi2sd(XMMRegister dst, Register src) {
vxorpd(dst, dst, dst);
vcvtlsi2sd(dst, dst, src);
} else {
xorps(dst, dst);
xorpd(dst, dst);
cvtlsi2sd(dst, src);
}
}
@ -805,7 +805,7 @@ void MacroAssembler::Cvtlsi2sd(XMMRegister dst, const Operand& src) {
vxorpd(dst, dst, dst);
vcvtlsi2sd(dst, dst, src);
} else {
xorps(dst, dst);
xorpd(dst, dst);
cvtlsi2sd(dst, src);
}
}
@ -2405,7 +2405,7 @@ void MacroAssembler::Move(const Operand& dst, Handle<Object> source) {
void MacroAssembler::Move(XMMRegister dst, uint32_t src) {
if (src == 0) {
xorps(dst, dst);
Xorpd(dst, dst);
} else {
unsigned pop = base::bits::CountPopulation32(src);
DCHECK_NE(0u, pop);
@ -2421,7 +2421,7 @@ void MacroAssembler::Move(XMMRegister dst, uint32_t src) {
void MacroAssembler::Move(XMMRegister dst, uint64_t src) {
if (src == 0) {
xorps(dst, dst);
Xorpd(dst, dst);
} else {
unsigned nlz = base::bits::CountLeadingZeros64(src);
unsigned ntz = base::bits::CountTrailingZeros64(src);
@ -2539,6 +2539,16 @@ void MacroAssembler::Movq(Register dst, XMMRegister src) {
}
void MacroAssembler::Xorpd(XMMRegister dst, XMMRegister src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vxorpd(dst, dst, src);
} else {
xorpd(dst, src);
}
}
void MacroAssembler::Cmp(Register dst, Handle<Object> source) {
AllowDeferredHandleDereference smi_check;
if (source->IsSmi()) {
@ -3234,7 +3244,7 @@ void MacroAssembler::ClampDoubleToUint8(XMMRegister input_reg,
Register result_reg) {
Label done;
Label conv_failure;
xorps(temp_xmm_reg, temp_xmm_reg);
Xorpd(temp_xmm_reg, temp_xmm_reg);
cvtsd2si(result_reg, input_reg);
testl(result_reg, Immediate(0xFFFFFF00));
j(zero, &done, Label::kNear);

View File

@ -808,7 +808,7 @@ class MacroAssembler: public Assembler {
// cvtsi2sd instruction only writes to the low 64-bit of dst register, which
// hinders register renaming and makes dependence chains longer. So we use
// xorps to clear the dst register before cvtsi2sd to solve this issue.
// xorpd to clear the dst register before cvtsi2sd to solve this issue.
void Cvtlsi2sd(XMMRegister dst, Register src);
void Cvtlsi2sd(XMMRegister dst, const Operand& src);
@ -905,6 +905,8 @@ class MacroAssembler: public Assembler {
void Movq(XMMRegister dst, Register src);
void Movq(Register dst, XMMRegister src);
void Xorpd(XMMRegister dst, XMMRegister src);
// Control Flow
void Jump(Address destination, RelocInfo::Mode rmode);
void Jump(ExternalReference ext);