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

Side by Side Diff: src/compiler/common-operator-reducer.cc

Issue 1205353002: [turbofan] Optimize BooleanNot conditions to Branch nodes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months 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
« no previous file with comments | « no previous file | src/macros.py » ('j') | src/macros.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/common-operator-reducer.h" 5 #include "src/compiler/common-operator-reducer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 default: 58 default:
59 break; 59 break;
60 } 60 }
61 return NoChange(); 61 return NoChange();
62 } 62 }
63 63
64 64
65 Reduction CommonOperatorReducer::ReduceBranch(Node* node) { 65 Reduction CommonOperatorReducer::ReduceBranch(Node* node) {
66 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); 66 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
67 Node* const cond = node->InputAt(0); 67 Node* const cond = node->InputAt(0);
68 // Swap IfTrue/IfFalse on {branch} if {cond} is a BooleanNot and use the input
69 // to BooleanNot as new condition for {branch}. Note we assume that {cond} was
70 // already properly optimized before we get here (as guaranteed by the graph
71 // reduction logic).
72 if (cond->opcode() == IrOpcode::kBooleanNot) {
73 for (Node* const use : node->uses()) {
74 switch (use->opcode()) {
75 case IrOpcode::kIfTrue:
76 use->set_op(common()->IfFalse());
77 break;
78 case IrOpcode::kIfFalse:
79 use->set_op(common()->IfTrue());
80 break;
81 default:
82 UNREACHABLE();
83 }
84 }
85 // Update the condition of {branch}. No need to mark the uses for revisit,
86 // since we tell the graph reducer that the {branch} was changed and the
87 // graph reduction logic will ensure that the uses are revisited properly.
88 node->ReplaceInput(0, cond->InputAt(0));
89 return Changed(node);
90 }
68 Decision const decision = DecideCondition(cond); 91 Decision const decision = DecideCondition(cond);
69 if (decision == Decision::kUnknown) return NoChange(); 92 if (decision == Decision::kUnknown) return NoChange();
70 Node* const control = node->InputAt(1); 93 Node* const control = node->InputAt(1);
71 if (!dead_.is_set()) dead_.set(graph()->NewNode(common()->Dead())); 94 if (!dead_.is_set()) dead_.set(graph()->NewNode(common()->Dead()));
72 for (Node* const use : node->uses()) { 95 for (Node* const use : node->uses()) {
73 switch (use->opcode()) { 96 switch (use->opcode()) {
74 case IrOpcode::kIfTrue: 97 case IrOpcode::kIfTrue:
75 Replace(use, (decision == Decision::kTrue) ? control : dead_.get()); 98 Replace(use, (decision == Decision::kTrue) ? control : dead_.get());
76 break; 99 break;
77 case IrOpcode::kIfFalse: 100 case IrOpcode::kIfFalse:
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 node->set_op(op); 325 node->set_op(op);
303 node->ReplaceInput(0, a); 326 node->ReplaceInput(0, a);
304 node->ReplaceInput(1, b); 327 node->ReplaceInput(1, b);
305 node->TrimInputCount(2); 328 node->TrimInputCount(2);
306 return Changed(node); 329 return Changed(node);
307 } 330 }
308 331
309 } // namespace compiler 332 } // namespace compiler
310 } // namespace internal 333 } // namespace internal
311 } // namespace v8 334 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/macros.py » ('j') | src/macros.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698