Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: src/compiler/select-lowering.cc

Issue 702463002: [turbofan] Introduce separate SelectLowering reducer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix windows Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/select-lowering.h ('k') | test/unittests/compiler/select-lowering-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/compiler/select-lowering.h"
6
7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/generic-node-inl.h"
9 #include "src/compiler/graph.h"
10
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14
15 SelectLowering::SelectLowering(Graph* graph, CommonOperatorBuilder* common)
16 : common_(common),
17 graph_(graph),
18 merges_(Merges::key_compare(), Merges::allocator_type(graph->zone())) {}
19
20
21 SelectLowering::~SelectLowering() {}
22
23
24 Reduction SelectLowering::Reduce(Node* node) {
25 if (node->opcode() != IrOpcode::kSelect) return NoChange();
26 SelectParameters const p = SelectParametersOf(node->op());
27
28 Node* const cond = node->InputAt(0);
29 Node* const control = graph()->start();
30
31 // Check if we already have a diamond for this condition.
32 auto i = merges_.find(cond);
33 if (i == merges_.end()) {
34 // Create a new diamond for this condition and remember its merge node.
35 Node* branch = graph()->NewNode(common()->Branch(p.hint()), cond, control);
36 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
37 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
38 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
39 i = merges_.insert(std::make_pair(cond, merge)).first;
40 }
41
42 DCHECK_EQ(cond, i->first);
43
44 // Create a Phi hanging off the previously determined merge.
45 node->set_op(common()->Phi(p.type(), 2));
46 node->ReplaceInput(0, node->InputAt(1));
47 node->ReplaceInput(1, node->InputAt(2));
48 node->ReplaceInput(2, i->second);
49 return Changed(node);
50 }
51
52 } // namespace compiler
53 } // namespace internal
54 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/select-lowering.h ('k') | test/unittests/compiler/select-lowering-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698