diff options
Diffstat (limited to 'deps/v8/src/compiler/machine-operator-reducer.cc')
-rw-r--r-- | deps/v8/src/compiler/machine-operator-reducer.cc | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/deps/v8/src/compiler/machine-operator-reducer.cc b/deps/v8/src/compiler/machine-operator-reducer.cc index 7fcba20e2e..8ef7e7ce08 100644 --- a/deps/v8/src/compiler/machine-operator-reducer.cc +++ b/deps/v8/src/compiler/machine-operator-reducer.cc @@ -22,7 +22,7 @@ MachineOperatorReducer::MachineOperatorReducer(MachineGraph* mcgraph, bool allow_signalling_nan) : mcgraph_(mcgraph), allow_signalling_nan_(allow_signalling_nan) {} -MachineOperatorReducer::~MachineOperatorReducer() {} +MachineOperatorReducer::~MachineOperatorReducer() = default; Node* MachineOperatorReducer::Float32Constant(volatile float value) { @@ -618,6 +618,12 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); break; } + case IrOpcode::kChangeFloat64ToInt64: { + Float64Matcher m(node->InputAt(0)); + if (m.HasValue()) return ReplaceInt64(static_cast<int64_t>(m.Value())); + if (m.IsChangeInt64ToFloat64()) return Replace(m.node()->InputAt(0)); + break; + } case IrOpcode::kChangeFloat64ToUint32: { Float64Matcher m(node->InputAt(0)); if (m.HasValue()) return ReplaceInt32(FastD2UI(m.Value())); @@ -634,6 +640,12 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { if (m.HasValue()) return ReplaceInt64(m.Value()); break; } + case IrOpcode::kChangeInt64ToFloat64: { + Int64Matcher m(node->InputAt(0)); + if (m.HasValue()) return ReplaceFloat64(static_cast<double>(m.Value())); + if (m.IsChangeFloat64ToInt64()) return Replace(m.node()->InputAt(0)); + break; + } case IrOpcode::kChangeUint32ToFloat64: { Uint32Matcher m(node->InputAt(0)); if (m.HasValue()) return ReplaceFloat64(FastUI2D(m.Value())); @@ -1374,21 +1386,32 @@ bool IsFloat64RepresentableAsFloat32(const Float64Matcher& m) { Reduction MachineOperatorReducer::ReduceFloat64Compare(Node* node) { - DCHECK((IrOpcode::kFloat64Equal == node->opcode()) || - (IrOpcode::kFloat64LessThan == node->opcode()) || - (IrOpcode::kFloat64LessThanOrEqual == node->opcode())); - // As all Float32 values have an exact representation in Float64, comparing - // two Float64 values both converted from Float32 is equivalent to comparing - // the original Float32s, so we can ignore the conversions. We can also reduce - // comparisons of converted Float64 values against constants that can be - // represented exactly as Float32. + DCHECK(IrOpcode::kFloat64Equal == node->opcode() || + IrOpcode::kFloat64LessThan == node->opcode() || + IrOpcode::kFloat64LessThanOrEqual == node->opcode()); Float64BinopMatcher m(node); - if ((m.left().IsChangeFloat32ToFloat64() && - m.right().IsChangeFloat32ToFloat64()) || - (m.left().IsChangeFloat32ToFloat64() && - IsFloat64RepresentableAsFloat32(m.right())) || - (IsFloat64RepresentableAsFloat32(m.left()) && - m.right().IsChangeFloat32ToFloat64())) { + if (m.IsFoldable()) { + switch (node->opcode()) { + case IrOpcode::kFloat64Equal: + return ReplaceBool(m.left().Value() == m.right().Value()); + case IrOpcode::kFloat64LessThan: + return ReplaceBool(m.left().Value() < m.right().Value()); + case IrOpcode::kFloat64LessThanOrEqual: + return ReplaceBool(m.left().Value() <= m.right().Value()); + default: + UNREACHABLE(); + } + } else if ((m.left().IsChangeFloat32ToFloat64() && + m.right().IsChangeFloat32ToFloat64()) || + (m.left().IsChangeFloat32ToFloat64() && + IsFloat64RepresentableAsFloat32(m.right())) || + (IsFloat64RepresentableAsFloat32(m.left()) && + m.right().IsChangeFloat32ToFloat64())) { + // As all Float32 values have an exact representation in Float64, comparing + // two Float64 values both converted from Float32 is equivalent to comparing + // the original Float32s, so we can ignore the conversions. We can also + // reduce comparisons of converted Float64 values against constants that + // can be represented exactly as Float32. switch (node->opcode()) { case IrOpcode::kFloat64Equal: NodeProperties::ChangeOp(node, machine()->Float32Equal()); @@ -1400,7 +1423,7 @@ Reduction MachineOperatorReducer::ReduceFloat64Compare(Node* node) { NodeProperties::ChangeOp(node, machine()->Float32LessThanOrEqual()); break; default: - return NoChange(); + UNREACHABLE(); } node->ReplaceInput( 0, m.left().HasValue() |