Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: src/compiler/x64/code-generator-x64.cc

Issue 1512023002: [turbofan] Change TruncateFloat32ToUint64 to TryTruncateFloat32ToUint64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added better mips64 code. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/compiler/x64/instruction-selector-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c86f4f22eef5babbd2fa271389bf2e20330ff41e..bb2902e2fb816c690a0bb3517a90969f6f5fe047 100644
--- a/src/compiler/x64/code-generator-x64.cc
+++ b/src/compiler/x64/code-generator-x64.cc
@@ -1068,6 +1068,19 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
}
break;
case kSSEFloat32ToUint64: {
+ Label done;
+ Label success;
+ if (instr->OutputCount() > 1) {
+ __ Set(i.OutputRegister(1), 0);
+ __ xorps(kScratchDoubleReg, kScratchDoubleReg);
+
+ if (instr->InputAt(0)->IsDoubleRegister()) {
+ __ Ucomiss(kScratchDoubleReg, i.InputDoubleRegister(0));
+ } else {
+ __ Ucomiss(kScratchDoubleReg, i.InputOperand(0));
+ }
+ __ j(above, &done);
+ }
// There does not exist a Float32ToUint64 instruction, so we have to use
// the Float32ToInt64 instruction.
if (instr->InputAt(0)->IsDoubleRegister()) {
@@ -1078,8 +1091,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
// Check if the result of the Float32ToInt64 conversion is positive, we
// are already done.
__ testq(i.OutputRegister(), i.OutputRegister());
- Label done;
- __ j(positive, &done);
+ __ j(positive, &success);
// The result of the first conversion was negative, which means that the
// input value was not within the positive int64 range. We subtract 2^64
// and convert it again to see if it is within the uint64 range.
@@ -1099,10 +1111,27 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
// earlier.
__ Set(kScratchRegister, 0x8000000000000000);
__ orq(i.OutputRegister(), kScratchRegister);
+ __ bind(&success);
+ if (instr->OutputCount() > 1) {
+ __ Set(i.OutputRegister(1), 1);
+ }
__ bind(&done);
break;
}
case kSSEFloat64ToUint64: {
+ Label done;
+ Label success;
+ if (instr->OutputCount() > 1) {
+ __ Set(i.OutputRegister(1), 0);
+ __ xorps(kScratchDoubleReg, kScratchDoubleReg);
+
+ if (instr->InputAt(0)->IsDoubleRegister()) {
+ __ Ucomisd(kScratchDoubleReg, i.InputDoubleRegister(0));
+ } else {
+ __ Ucomisd(kScratchDoubleReg, i.InputOperand(0));
+ }
+ __ j(above, &done);
+ }
// There does not exist a Float64ToUint64 instruction, so we have to use
// the Float64ToInt64 instruction.
if (instr->InputAt(0)->IsDoubleRegister()) {
@@ -1110,14 +1139,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
} else {
__ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0));
}
- if (instr->OutputCount() > 1) {
- __ Set(i.OutputRegister(1), 0);
- }
// Check if the result of the Float64ToInt64 conversion is positive, we
// are already done.
__ testq(i.OutputRegister(), i.OutputRegister());
- Label done;
- Label success;
__ j(positive, &success);
// The result of the first conversion was negative, which means that the
// input value was not within the positive int64 range. We subtract 2^64
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/compiler/x64/instruction-selector-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698