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

Unified Diff: src/compiler/control-reducer.cc

Issue 1053583005: [turbofan] Reduce duplication between ControlReducer::ReduceIf(True,False). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/control-reducer.cc
diff --git a/src/compiler/control-reducer.cc b/src/compiler/control-reducer.cc
index 8b41d19d1c75ce0c0e50b2897bf2bb19b49fce4b..25a680d62a544c5fcd5999bb5bb4a30dd3f2a860 100644
--- a/src/compiler/control-reducer.cc
+++ b/src/compiler/control-reducer.cc
@@ -416,9 +416,9 @@ class ControlReducerImpl {
case IrOpcode::kBranch:
return ReduceBranch(node);
case IrOpcode::kIfTrue:
- return ReduceIfTrue(node);
+ return ReduceIfProjection(node, kTrue);
case IrOpcode::kIfFalse:
- return ReduceIfFalse(node);
+ return ReduceIfProjection(node, kFalse);
case IrOpcode::kLoop:
case IrOpcode::kMerge:
return ReduceMerge(node);
@@ -576,27 +576,13 @@ class ControlReducerImpl {
return node;
}
- // Reduce branches if they have constant inputs.
- Node* ReduceIfTrue(Node* node) {
+ // Reduce if projections if the branch has a constant input.
+ Node* ReduceIfProjection(Node* node, Decision decision) {
Node* branch = node->InputAt(0);
DCHECK_EQ(IrOpcode::kBranch, branch->opcode());
Decision result = DecideCondition(branch->InputAt(0));
- if (result == kTrue) {
- // fold a true branch by replacing IfTrue with the branch control.
- TRACE(" BranchReduce: #%d:%s => #%d:%s\n", branch->id(),
- branch->op()->mnemonic(), node->id(), node->op()->mnemonic());
- return branch->InputAt(1);
- }
- return result == kUnknown ? node : dead();
- }
-
- // Reduce branches if they have constant inputs.
- Node* ReduceIfFalse(Node* node) {
- Node* branch = node->InputAt(0);
- DCHECK_EQ(IrOpcode::kBranch, branch->opcode());
- Decision result = DecideCondition(branch->InputAt(0));
- if (result == kFalse) {
- // fold a false branch by replacing IfFalse with the branch control.
+ if (result == decision) {
+ // Fold a branch by replacing IfTrue/IfFalse with the branch control.
TRACE(" BranchReduce: #%d:%s => #%d:%s\n", branch->id(),
branch->op()->mnemonic(), node->id(), node->op()->mnemonic());
return branch->InputAt(1);
@@ -681,9 +667,9 @@ Node* ControlReducer::ReduceIfNodeForTesting(JSGraph* jsgraph,
ControlReducerImpl impl(&zone, jsgraph, common);
switch (node->opcode()) {
case IrOpcode::kIfTrue:
- return impl.ReduceIfTrue(node);
+ return impl.ReduceIfProjection(node, kTrue);
case IrOpcode::kIfFalse:
- return impl.ReduceIfFalse(node);
+ return impl.ReduceIfProjection(node, kFalse);
default:
return node;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698