Commit b0eb6054 authored by ahaas's avatar ahaas Committed by Commit bot

[x64] Use Cvttsd2siq in TruncateDoubleToI for better performance.

R=verwaest@chromium.org, bmeurer@chromium.org
BUG=chromium:603470
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#35489}
parent df5976c9
......@@ -800,10 +800,13 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
auto result = i.OutputRegister();
auto input = i.InputDoubleRegister(0);
auto ool = new (zone()) OutOfLineTruncateDoubleToI(this, result, input);
__ Cvttsd2si(result, input);
__ cmpl(result, Immediate(1));
// We use Cvttsd2siq instead of Cvttsd2si due to performance reasons. The
// use of Cvttsd2siq requires the movl below to avoid sign extension.
__ Cvttsd2siq(result, input);
__ cmpq(result, Immediate(1));
__ j(overflow, ool->entry());
__ bind(ool->exit());
__ movl(result, result);
break;
}
case kArchStoreWithWriteBarrier: {
......
......@@ -3744,8 +3744,8 @@ void MacroAssembler::TruncateHeapNumberToI(Register result_reg,
Register input_reg) {
Label done;
Movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
Cvttsd2si(result_reg, xmm0);
cmpl(result_reg, Immediate(1));
Cvttsd2siq(result_reg, xmm0);
cmpq(result_reg, Immediate(1));
j(no_overflow, &done, Label::kNear);
// Slow case.
......@@ -3767,8 +3767,8 @@ void MacroAssembler::TruncateHeapNumberToI(Register result_reg,
void MacroAssembler::TruncateDoubleToI(Register result_reg,
XMMRegister input_reg) {
Label done;
Cvttsd2si(result_reg, input_reg);
cmpl(result_reg, Immediate(1));
Cvttsd2siq(result_reg, input_reg);
cmpq(result_reg, Immediate(1));
j(no_overflow, &done, Label::kNear);
subp(rsp, Immediate(kDoubleSize));
......
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