X87: [turbofan] Add TruncationMode for TruncateFloat64ToInt32.
port 4b38c15817
(r29527).
original commit message:
We actually need round to zero truncation to implement the counterpart
of LDoubleToI in TurboFan, which tries to convert a double to an integer
as required for keyed load/store optimizations.
Drive-by-cleanup: Reduce some code duplication in the InstructionSelector
implementations.
BUG=
Review URL: https://codereview.chromium.org/1227923003
Cr-Commit-Position: refs/heads/master@{#29629}
This commit is contained in:
parent
1b20d50594
commit
a02e644c50
src/compiler/x87
@ -422,11 +422,13 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
|
||||
__ mov(i.OutputRegister(), esp);
|
||||
break;
|
||||
case kArchTruncateDoubleToI: {
|
||||
auto input = i.InputDoubleRegister(0);
|
||||
USE(input);
|
||||
DCHECK(input.code() == 0);
|
||||
auto result_reg = i.OutputRegister();
|
||||
__ TruncateX87TOSToI(result_reg);
|
||||
if (!instr->InputAt(0)->IsDoubleRegister()) {
|
||||
__ fld_d(i.InputOperand(0));
|
||||
}
|
||||
__ TruncateX87TOSToI(i.OutputRegister());
|
||||
if (!instr->InputAt(0)->IsDoubleRegister()) {
|
||||
__ fstp(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kX87Add:
|
||||
|
@ -647,6 +647,23 @@ void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) {
|
||||
}
|
||||
|
||||
|
||||
void InstructionSelector::VisitTruncateFloat64ToInt32(Node* node) {
|
||||
X87OperandGenerator g(this);
|
||||
|
||||
switch (TruncationModeOf(node->op())) {
|
||||
case TruncationMode::kJavaScript:
|
||||
Emit(kArchTruncateDoubleToI, g.DefineAsRegister(node),
|
||||
g.Use(node->InputAt(0)));
|
||||
return;
|
||||
case TruncationMode::kRoundToZero:
|
||||
Emit(kX87Float64ToInt32, g.DefineAsRegister(node),
|
||||
g.Use(node->InputAt(0)));
|
||||
return;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
void InstructionSelector::VisitFloat32Add(Node* node) {
|
||||
X87OperandGenerator g(this);
|
||||
Emit(kX87PushFloat32, g.NoOutput(), g.Use(node->InputAt(0)));
|
||||
|
Loading…
Reference in New Issue
Block a user