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

Unified Diff: src/compiler/common-operator-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 | « no previous file | src/compiler/control-flow-optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/common-operator-reducer.cc
diff --git a/src/compiler/common-operator-reducer.cc b/src/compiler/common-operator-reducer.cc
index b07383d21c5ed7b554273d24f98d933ab8808d98..c66cce0538794f8019fba27966bc3181b088113d 100644
--- a/src/compiler/common-operator-reducer.cc
+++ b/src/compiler/common-operator-reducer.cc
@@ -51,17 +51,10 @@ Reduction CommonOperatorReducer::ReducePhi(Node* node) {
Node* vtrue = NodeProperties::GetValueInput(node, 0);
Node* vfalse = NodeProperties::GetValueInput(node, 1);
Node* merge = NodeProperties::GetControlInput(node);
- Node* if_true = NodeProperties::GetControlInput(merge, 0);
- Node* if_false = NodeProperties::GetControlInput(merge, 1);
- if (if_true->opcode() != IrOpcode::kIfTrue) {
- std::swap(if_true, if_false);
- std::swap(vtrue, vfalse);
- }
- if (if_true->opcode() == IrOpcode::kIfTrue &&
- if_false->opcode() == IrOpcode::kIfFalse &&
- if_true->InputAt(0) == if_false->InputAt(0)) {
- Node* branch = if_true->InputAt(0);
- Node* cond = branch->InputAt(0);
+ DiamondMatcher matcher(merge);
+ if (matcher.Matched()) {
+ if (matcher.IfTrue() == merge->InputAt(1)) std::swap(vtrue, vfalse);
+ Node* cond = matcher.Branch()->InputAt(0);
if (cond->opcode() == IrOpcode::kFloat64LessThan) {
if (cond->InputAt(0) == vtrue && cond->InputAt(1) == vfalse &&
machine()->HasFloat64Min()) {
« no previous file with comments | « no previous file | src/compiler/control-flow-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698