Commit 6f8630ed authored by ahaas's avatar ahaas Committed by Commit bot

[x64] Avoid the sign extension in the DoubleToI conversion.

We use the cvttsd2si (float64-to-int32) instruction to avoid that negative numbers get sign extended in the destination register.

@rodolph: Is sign extension also a thing on arm64? I noticed that also on arm64 a float64-to-int64 instruction is used.

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

Cr-Commit-Position: refs/heads/master@{#35466}
parent b0e14e14
......@@ -791,8 +791,8 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
auto result = i.OutputRegister();
auto input = i.InputDoubleRegister(0);
auto ool = new (zone()) OutOfLineTruncateDoubleToI(this, result, input);
__ Cvttsd2siq(result, input);
__ cmpq(result, Immediate(1));
__ Cvttsd2si(result, input);
__ cmpl(result, Immediate(1));
__ j(overflow, ool->entry());
__ bind(ool->exit());
break;
......
......@@ -3744,8 +3744,8 @@ void MacroAssembler::TruncateHeapNumberToI(Register result_reg,
Register input_reg) {
Label done;
Movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
Cvttsd2siq(result_reg, xmm0);
cmpq(result_reg, Immediate(1));
Cvttsd2si(result_reg, xmm0);
cmpl(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;
Cvttsd2siq(result_reg, input_reg);
cmpq(result_reg, Immediate(1));
Cvttsd2si(result_reg, input_reg);
cmpl(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