Index: src/compiler/x64/code-generator-x64.cc |
diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc |
index dd54431f023527eeb464360794d53228493f4d0c..f641ece28f2c584a7793581b5d52f8549fe1406c 100644 |
--- a/src/compiler/x64/code-generator-x64.cc |
+++ b/src/compiler/x64/code-generator-x64.cc |
@@ -1053,8 +1053,26 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
__ Cvttss2siq(i.OutputRegister(), i.InputOperand(0)); |
} |
if (instr->OutputCount() > 1) { |
- __ Set(i.OutputRegister(1), 0x8000000000000000); |
- __ subq(i.OutputRegister(1), i.OutputRegister(0)); |
+ __ Set(i.OutputRegister(1), 1); |
+ Label done; |
+ Label fail; |
+ __ Move(kScratchDoubleReg, -9223372036854775808.0f); |
Michael Starzinger
2015/12/16 13:01:29
Likewise for magic number.
ahaas
2015/12/16 14:35:24
Done.
|
+ if (instr->InputAt(0)->IsDoubleRegister()) { |
+ __ Ucomiss(kScratchDoubleReg, i.InputDoubleRegister(0)); |
+ } else { |
+ __ Ucomiss(kScratchDoubleReg, i.InputOperand(0)); |
+ } |
+ // If the input is NaN, then the conversion fails. |
+ __ j(parity_even, &fail); |
+ // If the input is INT64_MIN, then the conversion succeeds. |
+ __ j(equal, &done); |
+ __ cmpq(i.OutputRegister(0), Immediate(1)); |
+ // If the conversion results in INT64_MIN, but the input was not |
+ // INT64_MIN, then the conversion fails. |
+ __ j(no_overflow, &done); |
+ __ bind(&fail); |
+ __ Set(i.OutputRegister(1), 0); |
+ __ bind(&done); |
} |
break; |
case kSSEFloat64ToInt64: |
@@ -1064,8 +1082,26 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
__ Cvttsd2siq(i.OutputRegister(0), i.InputOperand(0)); |
} |
if (instr->OutputCount() > 1) { |
- __ Set(i.OutputRegister(1), 0x8000000000000000); |
- __ subq(i.OutputRegister(1), i.OutputRegister(0)); |
+ __ Set(i.OutputRegister(1), 1); |
+ Label done; |
+ Label fail; |
+ __ Move(kScratchDoubleReg, -9223372036854775808.0); |
Michael Starzinger
2015/12/16 13:01:29
Likewise for magic number.
ahaas
2015/12/16 14:35:23
Done.
|
+ if (instr->InputAt(0)->IsDoubleRegister()) { |
+ __ Ucomisd(kScratchDoubleReg, i.InputDoubleRegister(0)); |
+ } else { |
+ __ Ucomisd(kScratchDoubleReg, i.InputOperand(0)); |
+ } |
+ // If the input is NaN, then the conversion fails. |
+ __ j(parity_even, &fail); |
+ // If the input is INT64_MIN, then the conversion succeeds. |
+ __ j(equal, &done); |
+ __ cmpq(i.OutputRegister(0), Immediate(1)); |
+ // If the conversion results in INT64_MIN, but the input was not |
+ // INT64_MIN, then the conversion fails. |
+ __ j(no_overflow, &done); |
+ __ bind(&fail); |
+ __ Set(i.OutputRegister(1), 0); |
+ __ bind(&done); |
} |
break; |
case kSSEFloat32ToUint64: { |