Commit 82581534 authored by titzer@chromium.org's avatar titzer@chromium.org

Implement control reducer, which reduces branches and phis together in a single fixpoint.

R=bmeurer@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#24891}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24891 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 76bc15b5
This diff is collapsed.
...@@ -11,6 +11,7 @@ namespace compiler { ...@@ -11,6 +11,7 @@ namespace compiler {
class JSGraph; class JSGraph;
class CommonOperatorBuilder; class CommonOperatorBuilder;
class Node;
class ControlReducer { class ControlReducer {
public: public:
...@@ -20,6 +21,16 @@ class ControlReducer { ...@@ -20,6 +21,16 @@ class ControlReducer {
// Trim nodes in the graph that are not reachable from end. // Trim nodes in the graph that are not reachable from end.
static void TrimGraph(Zone* zone, JSGraph* graph); static void TrimGraph(Zone* zone, JSGraph* graph);
// Testing interface.
static Node* ReducePhiForTesting(JSGraph* graph,
CommonOperatorBuilder* builder, Node* node);
static Node* ReduceBranchForTesting(JSGraph* graph,
CommonOperatorBuilder* builder,
Node* node);
static Node* ReduceMergeForTesting(JSGraph* graph,
CommonOperatorBuilder* builder,
Node* node);
}; };
} }
} }
......
...@@ -117,6 +117,7 @@ inline int OperatorProperties::GetEffectInputCount(const Operator* op) { ...@@ -117,6 +117,7 @@ inline int OperatorProperties::GetEffectInputCount(const Operator* op) {
} }
inline int OperatorProperties::GetControlInputCount(const Operator* op) { inline int OperatorProperties::GetControlInputCount(const Operator* op) {
// TODO(titzer): fix this mess; just make them a count on the operator.
switch (op->opcode()) { switch (op->opcode()) {
case IrOpcode::kPhi: case IrOpcode::kPhi:
case IrOpcode::kEffectPhi: case IrOpcode::kEffectPhi:
...@@ -127,8 +128,8 @@ inline int OperatorProperties::GetControlInputCount(const Operator* op) { ...@@ -127,8 +128,8 @@ inline int OperatorProperties::GetControlInputCount(const Operator* op) {
#define OPCODE_CASE(x) case IrOpcode::k##x: #define OPCODE_CASE(x) case IrOpcode::k##x:
CONTROL_OP_LIST(OPCODE_CASE) CONTROL_OP_LIST(OPCODE_CASE)
#undef OPCODE_CASE #undef OPCODE_CASE
// Branch operator is special
if (op->opcode() == IrOpcode::kBranch) return 1; if (op->opcode() == IrOpcode::kBranch) return 1;
if (op->opcode() == IrOpcode::kTerminate) return 1;
// Control operators are Operator1<int>. // Control operators are Operator1<int>.
return OpParameter<int>(op); return OpParameter<int>(op);
default: default:
......
...@@ -382,7 +382,8 @@ class CFGBuilder { ...@@ -382,7 +382,8 @@ class CFGBuilder {
} }
bool IsFinalMerge(Node* node) { bool IsFinalMerge(Node* node) {
return (node == scheduler_->graph_->end()->InputAt(0)); return (node->opcode() == IrOpcode::kMerge &&
node == scheduler_->graph_->end()->InputAt(0));
} }
}; };
......
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