Commit 03fbb053 authored by Benedikt Meurer's avatar Benedikt Meurer

[x86] Use AVX in Crankshaft when available.

R=verwaest@chromium.org

Committed: https://crrev.com/622be8f71e70b6ece4ea6a89bcfa1bc4be5e70c1
Cr-Commit-Position: refs/heads/master@{#26159}

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

Cr-Commit-Position: refs/heads/master@{#26235}
parent 9e99a604
...@@ -1981,19 +1981,43 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) { ...@@ -1981,19 +1981,43 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
XMMRegister result = ToDoubleRegister(instr->result()); XMMRegister result = ToDoubleRegister(instr->result());
switch (instr->op()) { switch (instr->op()) {
case Token::ADD: case Token::ADD:
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(masm(), AVX);
__ vaddsd(result, left, right);
} else {
DCHECK(result.is(left));
__ addsd(left, right); __ addsd(left, right);
}
break; break;
case Token::SUB: case Token::SUB:
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(masm(), AVX);
__ vsubsd(result, left, right);
} else {
DCHECK(result.is(left));
__ subsd(left, right); __ subsd(left, right);
}
break; break;
case Token::MUL: case Token::MUL:
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(masm(), AVX);
__ vmulsd(result, left, right);
} else {
DCHECK(result.is(left));
__ mulsd(left, right); __ mulsd(left, right);
}
break; break;
case Token::DIV: case Token::DIV:
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(masm(), AVX);
__ vdivsd(result, left, right);
} else {
DCHECK(result.is(left));
__ divsd(left, right); __ divsd(left, right);
// Don't delete this mov. It may improve performance on some CPUs, // Don't delete this mov. It may improve performance on some CPUs,
// when there is a mulsd depending on the result // when there is a mulsd depending on the result
__ movaps(left, left); __ movaps(left, left);
}
break; break;
case Token::MOD: { case Token::MOD: {
// Pass two doubles as arguments on the stack. // Pass two doubles as arguments on the stack.
......
...@@ -765,7 +765,8 @@ LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, ...@@ -765,7 +765,8 @@ LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op,
LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); LOperand* right = UseRegisterAtStart(instr->BetterRightOperand());
LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); LArithmeticD* result = new(zone()) LArithmeticD(op, left, right);
return DefineSameAsFirst(result); return CpuFeatures::IsSupported(AVX) ? DefineAsRegister(result)
: DefineSameAsFirst(result);
} }
} }
......
...@@ -2002,23 +2002,45 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) { ...@@ -2002,23 +2002,45 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
XMMRegister left = ToDoubleRegister(instr->left()); XMMRegister left = ToDoubleRegister(instr->left());
XMMRegister right = ToDoubleRegister(instr->right()); XMMRegister right = ToDoubleRegister(instr->right());
XMMRegister result = ToDoubleRegister(instr->result()); XMMRegister result = ToDoubleRegister(instr->result());
// All operations except MOD are computed in-place.
DCHECK(instr->op() == Token::MOD || left.is(result));
switch (instr->op()) { switch (instr->op()) {
case Token::ADD: case Token::ADD:
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(masm(), AVX);
__ vaddsd(result, left, right);
} else {
DCHECK(result.is(left));
__ addsd(left, right); __ addsd(left, right);
}
break; break;
case Token::SUB: case Token::SUB:
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(masm(), AVX);
__ vsubsd(result, left, right);
} else {
DCHECK(result.is(left));
__ subsd(left, right); __ subsd(left, right);
}
break; break;
case Token::MUL: case Token::MUL:
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(masm(), AVX);
__ vmulsd(result, left, right);
} else {
DCHECK(result.is(left));
__ mulsd(left, right); __ mulsd(left, right);
}
break; break;
case Token::DIV: case Token::DIV:
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(masm(), AVX);
__ vdivsd(result, left, right);
} else {
DCHECK(result.is(left));
__ divsd(left, right); __ divsd(left, right);
// Don't delete this mov. It may improve performance on some CPUs, // Don't delete this mov. It may improve performance on some CPUs,
// when there is a mulsd depending on the result // when there is a mulsd depending on the result
__ movaps(left, left); __ movaps(left, left);
}
break; break;
case Token::MOD: { case Token::MOD: {
XMMRegister xmm_scratch = double_scratch0(); XMMRegister xmm_scratch = double_scratch0();
......
...@@ -748,7 +748,8 @@ LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, ...@@ -748,7 +748,8 @@ LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op,
LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); LOperand* right = UseRegisterAtStart(instr->BetterRightOperand());
LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); LArithmeticD* result = new(zone()) LArithmeticD(op, left, right);
return DefineSameAsFirst(result); return CpuFeatures::IsSupported(AVX) ? DefineAsRegister(result)
: DefineSameAsFirst(result);
} }
} }
......
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