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

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

Issue 1054963002: [turbofan] Introduce BranchMatcher and DiamondMatcher helpers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | « src/compiler/control-flow-optimizer.cc ('k') | src/compiler/node-matchers.h » ('j') | 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 238b510671d7e79af7a128fae9626193a283790a..08182703b4bac886e4112ae517f17c822c738df4 100644
--- a/src/compiler/control-reducer.cc
+++ b/src/compiler/control-reducer.cc
@@ -566,25 +566,17 @@ class ControlReducerImpl {
// Check if it's an unused diamond.
if (live == 2 && phis.empty()) {
- Node* node0 = node->InputAt(0);
- Node* node1 = node->InputAt(1);
- if (((node0->opcode() == IrOpcode::kIfTrue &&
- node1->opcode() == IrOpcode::kIfFalse) ||
- (node1->opcode() == IrOpcode::kIfTrue &&
- node0->opcode() == IrOpcode::kIfFalse)) &&
- node0->OwnedBy(node) && node1->OwnedBy(node)) {
- Node* branch0 = NodeProperties::GetControlInput(node0);
- Node* branch1 = NodeProperties::GetControlInput(node1);
- if (branch0 == branch1) {
- // It's a dead diamond, i.e. neither the IfTrue nor the IfFalse nodes
- // have users except for the Merge and the Merge has no Phi or
- // EffectPhi uses, so replace the Merge with the control input of the
- // diamond.
- TRACE(" DeadDiamond: #%d:%s #%d:%s #%d:%s\n", node0->id(),
- node0->op()->mnemonic(), node1->id(), node1->op()->mnemonic(),
- branch0->id(), branch0->op()->mnemonic());
- return NodeProperties::GetControlInput(branch0);
- }
+ DiamondMatcher matcher(node);
+ if (matcher.Matched() && matcher.IfProjectionsAreOwned()) {
+ // It's a dead diamond, i.e. neither the IfTrue nor the IfFalse nodes
+ // have uses except for the Merge and the Merge has no Phi or
+ // EffectPhi uses, so replace the Merge with the control input of the
+ // diamond.
+ TRACE(" DeadDiamond: #%d:Branch #%d:IfTrue #%d:IfFalse\n",
+ matcher.Branch()->id(), matcher.IfTrue()->id(),
+ matcher.IfFalse()->id());
+ // TODO(turbofan): replace single-phi diamonds with selects.
+ return NodeProperties::GetControlInput(matcher.Branch());
}
}
« no previous file with comments | « src/compiler/control-flow-optimizer.cc ('k') | src/compiler/node-matchers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698