Commit 19482d29 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Remove the useless SimplifiedOperatorReducer.

The SimplifiedOperatorReducer is (mostly) unused, except for the very
rough store elimination, and just eats compilation time.

R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28673}
parent 388e791d
......@@ -729,8 +729,6 @@ source_set("v8_base") {
"src/compiler/select-lowering.h",
"src/compiler/simplified-lowering.cc",
"src/compiler/simplified-lowering.h",
"src/compiler/simplified-operator-reducer.cc",
"src/compiler/simplified-operator-reducer.h",
"src/compiler/simplified-operator.cc",
"src/compiler/simplified-operator.h",
"src/compiler/source-position.cc",
......
......@@ -43,7 +43,6 @@
#include "src/compiler/scheduler.h"
#include "src/compiler/select-lowering.h"
#include "src/compiler/simplified-lowering.h"
#include "src/compiler/simplified-operator-reducer.h"
#include "src/compiler/tail-call-optimization.h"
#include "src/compiler/typer.h"
#include "src/compiler/value-numbering-reducer.h"
......@@ -569,13 +568,11 @@ struct TypedLoweringPhase {
data->info()->is_deoptimization_enabled()
? JSIntrinsicLowering::kDeoptimizationEnabled
: JSIntrinsicLowering::kDeoptimizationDisabled);
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
CommonOperatorReducer common_reducer(data->jsgraph());
AddReducer(data, &graph_reducer, &builtin_reducer);
AddReducer(data, &graph_reducer, &typed_lowering);
AddReducer(data, &graph_reducer, &intrinsic_lowering);
AddReducer(data, &graph_reducer, &load_elimination);
AddReducer(data, &graph_reducer, &simple_reducer);
AddReducer(data, &graph_reducer, &common_reducer);
graph_reducer.ReduceGraph();
}
......@@ -590,12 +587,10 @@ struct SimplifiedLoweringPhase {
data->source_positions());
lowering.LowerAllNodes();
ValueNumberingReducer vn_reducer(temp_zone);
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
MachineOperatorReducer machine_reducer(data->jsgraph());
CommonOperatorReducer common_reducer(data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone);
AddReducer(data, &graph_reducer, &vn_reducer);
AddReducer(data, &graph_reducer, &simple_reducer);
AddReducer(data, &graph_reducer, &machine_reducer);
AddReducer(data, &graph_reducer, &common_reducer);
graph_reducer.ReduceGraph();
......@@ -618,13 +613,11 @@ struct ChangeLoweringPhase {
void Run(PipelineData* data, Zone* temp_zone) {
ValueNumberingReducer vn_reducer(temp_zone);
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
ChangeLowering lowering(data->jsgraph());
MachineOperatorReducer machine_reducer(data->jsgraph());
CommonOperatorReducer common_reducer(data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone);
AddReducer(data, &graph_reducer, &vn_reducer);
AddReducer(data, &graph_reducer, &simple_reducer);
AddReducer(data, &graph_reducer, &lowering);
AddReducer(data, &graph_reducer, &machine_reducer);
AddReducer(data, &graph_reducer, &common_reducer);
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/simplified-operator-reducer.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/operator-properties.h"
namespace v8 {
namespace internal {
namespace compiler {
SimplifiedOperatorReducer::SimplifiedOperatorReducer(JSGraph* jsgraph)
: jsgraph_(jsgraph), simplified_(jsgraph->zone()) {}
SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {}
Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
switch (node->opcode()) {
case IrOpcode::kBooleanNot: {
HeapObjectMatcher<HeapObject> m(node->InputAt(0));
if (m.Is(Unique<HeapObject>::CreateImmovable(factory()->false_value()))) {
return Replace(jsgraph()->TrueConstant());
}
if (m.Is(Unique<HeapObject>::CreateImmovable(factory()->true_value()))) {
return Replace(jsgraph()->FalseConstant());
}
if (m.IsBooleanNot()) return Replace(m.node()->InputAt(0));
break;
}
case IrOpcode::kChangeBitToBool: {
Int32Matcher m(node->InputAt(0));
if (m.Is(0)) return Replace(jsgraph()->FalseConstant());
if (m.Is(1)) return Replace(jsgraph()->TrueConstant());
if (m.IsChangeBoolToBit()) return Replace(m.node()->InputAt(0));
break;
}
case IrOpcode::kChangeBoolToBit: {
HeapObjectMatcher<HeapObject> m(node->InputAt(0));
if (m.Is(Unique<HeapObject>::CreateImmovable(factory()->false_value()))) {
return ReplaceInt32(0);
}
if (m.Is(Unique<HeapObject>::CreateImmovable(factory()->true_value()))) {
return ReplaceInt32(1);
}
if (m.IsChangeBitToBool()) return Replace(m.node()->InputAt(0));
break;
}
case IrOpcode::kChangeFloat64ToTagged: {
Float64Matcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceNumber(m.Value());
break;
}
case IrOpcode::kChangeInt32ToTagged: {
Int32Matcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceNumber(m.Value());
break;
}
case IrOpcode::kChangeTaggedToFloat64: {
NumberMatcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceFloat64(m.Value());
if (m.IsChangeFloat64ToTagged()) return Replace(m.node()->InputAt(0));
if (m.IsChangeInt32ToTagged()) {
return Change(node, machine()->ChangeInt32ToFloat64(),
m.node()->InputAt(0));
}
if (m.IsChangeUint32ToTagged()) {
return Change(node, machine()->ChangeUint32ToFloat64(),
m.node()->InputAt(0));
}
break;
}
case IrOpcode::kChangeTaggedToInt32: {
NumberMatcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
if (m.IsChangeFloat64ToTagged()) {
return Change(node, machine()->ChangeFloat64ToInt32(),
m.node()->InputAt(0));
}
if (m.IsChangeInt32ToTagged()) return Replace(m.node()->InputAt(0));
break;
}
case IrOpcode::kChangeTaggedToUint32: {
NumberMatcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceUint32(DoubleToUint32(m.Value()));
if (m.IsChangeFloat64ToTagged()) {
return Change(node, machine()->ChangeFloat64ToUint32(),
m.node()->InputAt(0));
}
if (m.IsChangeUint32ToTagged()) return Replace(m.node()->InputAt(0));
break;
}
case IrOpcode::kChangeUint32ToTagged: {
Uint32Matcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value()));
break;
}
case IrOpcode::kStoreField: {
// TODO(turbofan): Poor man's store elimination, remove this once we have
// a fully featured store elimination in place.
Node* const effect = node->InputAt(2);
if (effect->op()->Equals(node->op()) && effect->OwnedBy(node) &&
effect->InputAt(0) == node->InputAt(0)) {
// The {effect} is a store to the same field in the same object, and
// {node} is the only effect observer, so we can kill {effect} and
// instead make {node} depend on the incoming effect to {effect}.
node->ReplaceInput(2, effect->InputAt(2));
effect->Kill();
return Changed(node);
}
break;
}
default:
break;
}
return NoChange();
}
Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op,
Node* a) {
DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op));
DCHECK_LE(1, node->InputCount());
node->set_op(op);
node->ReplaceInput(0, a);
return Changed(node);
}
Reduction SimplifiedOperatorReducer::ReplaceFloat64(double value) {
return Replace(jsgraph()->Float64Constant(value));
}
Reduction SimplifiedOperatorReducer::ReplaceInt32(int32_t value) {
return Replace(jsgraph()->Int32Constant(value));
}
Reduction SimplifiedOperatorReducer::ReplaceNumber(double value) {
return Replace(jsgraph()->Constant(value));
}
Reduction SimplifiedOperatorReducer::ReplaceNumber(int32_t value) {
return Replace(jsgraph()->Constant(value));
}
Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); }
Factory* SimplifiedOperatorReducer::factory() const {
return jsgraph()->isolate()->factory();
}
MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const {
return jsgraph()->machine();
}
} // namespace compiler
} // namespace internal
} // namespace v8
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
#define V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
#include "src/compiler/graph-reducer.h"
#include "src/compiler/simplified-operator.h"
namespace v8 {
namespace internal {
// Forward declarations.
class Factory;
class Heap;
namespace compiler {
// Forward declarations.
class JSGraph;
class MachineOperatorBuilder;
class SimplifiedOperatorReducer final : public Reducer {
public:
explicit SimplifiedOperatorReducer(JSGraph* jsgraph);
~SimplifiedOperatorReducer() final;
Reduction Reduce(Node* node) final;
private:
Reduction Change(Node* node, const Operator* op, Node* a);
Reduction ReplaceFloat64(double value);
Reduction ReplaceInt32(int32_t value);
Reduction ReplaceUint32(uint32_t value) {
return ReplaceInt32(bit_cast<int32_t>(value));
}
Reduction ReplaceNumber(double value);
Reduction ReplaceNumber(int32_t value);
Graph* graph() const;
Factory* factory() const;
JSGraph* jsgraph() const { return jsgraph_; }
MachineOperatorBuilder* machine() const;
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
JSGraph* jsgraph_;
SimplifiedOperatorBuilder simplified_;
DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer);
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
......@@ -76,7 +76,6 @@
'compiler/schedule-unittest.cc',
'compiler/select-lowering-unittest.cc',
'compiler/scheduler-unittest.cc',
'compiler/simplified-operator-reducer-unittest.cc',
'compiler/simplified-operator-unittest.cc',
'compiler/state-values-utils-unittest.cc',
'compiler/tail-call-optimization-unittest.cc',
......
......@@ -560,8 +560,6 @@
'../../src/compiler/select-lowering.h',
'../../src/compiler/simplified-lowering.cc',
'../../src/compiler/simplified-lowering.h',
'../../src/compiler/simplified-operator-reducer.cc',
'../../src/compiler/simplified-operator-reducer.h',
'../../src/compiler/simplified-operator.cc',
'../../src/compiler/simplified-operator.h',
'../../src/compiler/source-position.cc',
......
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