Home | History | Annotate | Download | only in compiler

Lines Matching refs:Node

9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties.h"
31 Node* node = queue_.front();
33 if (node->IsDead()) continue;
34 switch (node->opcode()) {
36 VisitBranch(node);
39 VisitNode(node);
46 void ControlFlowOptimizer::Enqueue(Node* node) {
47 DCHECK_NOT_NULL(node);
48 if (node->IsDead() || queued_.Get(node)) return;
49 queued_.Set(node, true);
50 queue_.push(node);
54 void ControlFlowOptimizer::VisitNode(Node* node) {
55 for (Edge edge : node->use_edges()) {
63 void ControlFlowOptimizer::VisitBranch(Node* node) {
64 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
65 if (TryBuildSwitch(node)) return;
66 if (TryCloneBranch(node)) return;
67 VisitNode(node);
71 bool ControlFlowOptimizer::TryCloneBranch(Node* node) {
72 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
75 // input graph as shown below and clones the Branch node for every predecessor
123 Node* branch = node;
124 Node* cond = NodeProperties::GetValueInput(branch, 0);
126 Node* merge = NodeProperties::GetControlInput(branch);
135 for (Node* const use : merge->uses()) {
149 Node* control = NodeProperties::GetControlInput(edge.from());
161 Node** const inputs = zone()->NewArray<Node*>(2 * input_count);
162 Node** const merge_true_inputs = &inputs[0];
163 Node** const merge_false_inputs = &inputs[input_count];
165 Node* cond1 = NodeProperties::GetValueInput(cond, index);
166 Node* control1 = NodeProperties::GetControlInput(merge, index);
167 Node* branch1 = graph()->NewNode(common()->Branch(hint), cond1, control1);
172 Node* const merge_true = graph()->NewNode(common()->Merge(input_count),
174 Node* const merge_false = graph()->NewNode(common()->Merge(input_count),
176 for (Node* const phi : phis) {
181 Node* phi_true = graph()->NewNode(phi->op(), input_count + 1, inputs);
183 Node* phi_false = graph()->NewNode(phi->op(), input_count + 1, inputs);
185 Node* control = NodeProperties::GetControlInput(edge.from());
206 bool ControlFlowOptimizer::TryBuildSwitch(Node* node) {
207 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
209 Node* branch = node;
211 Node* cond = NodeProperties::GetValueInput(branch, 0);
214 Node* index = m.left().node();
220 Node* if_false;
221 Node* if_true;
231 Node* branch1 = *it++;
235 Node* cond1 = branch1->InputAt(0);
238 if (m1.left().node() != index) break;
244 if (branch != node) {
246 if_true->ReplaceInput(0, node);
257 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
259 if (branch == node) {
264 node->ReplaceInput(0, index);
265 NodeProperties::ChangeOp(node, common()->Switch(values.size() + 1));
266 if_true->ReplaceInput(0, node);
269 if_false->ReplaceInput(0, node);