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

Unified Diff: test/unittests/compiler/control-flow-optimizer-unittest.cc

Issue 947963002: [turbofan] Initial version of branch cloning. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tests and documentation. Created 5 years, 10 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 | « test/mjsunit/asm/if-cloning.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/control-flow-optimizer-unittest.cc
diff --git a/test/unittests/compiler/control-flow-optimizer-unittest.cc b/test/unittests/compiler/control-flow-optimizer-unittest.cc
index c083d4bab5c62afd6c2e23e7f2c659a3e69bf10e..f5c182934ba08ec5d481928c93d8dd0622125622 100644
--- a/test/unittests/compiler/control-flow-optimizer-unittest.cc
+++ b/test/unittests/compiler/control-flow-optimizer-unittest.cc
@@ -39,7 +39,7 @@ class ControlFlowOptimizerTest : public GraphTest {
};
-TEST_F(ControlFlowOptimizerTest, Switch) {
+TEST_F(ControlFlowOptimizerTest, BuildSwitch) {
Node* index = Parameter(0);
Node* branch0 = graph()->NewNode(
common()->Branch(),
@@ -65,6 +65,34 @@ TEST_F(ControlFlowOptimizerTest, Switch) {
IsSwitch(index, start()))))));
}
+
+TEST_F(ControlFlowOptimizerTest, CloneBranch) {
+ Node* cond0 = Parameter(0);
+ Node* cond1 = Parameter(1);
+ Node* cond2 = Parameter(2);
+ Node* branch0 = graph()->NewNode(common()->Branch(), cond0, start());
+ Node* control1 = graph()->NewNode(common()->IfTrue(), branch0);
+ Node* control2 = graph()->NewNode(common()->IfFalse(), branch0);
+ Node* merge0 = graph()->NewNode(common()->Merge(2), control1, control2);
+ Node* phi0 =
+ graph()->NewNode(common()->Phi(kRepBit, 2), cond1, cond2, merge0);
+ Node* branch = graph()->NewNode(common()->Branch(), phi0, merge0);
+ Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
+ Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
+ Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
+ graph()->SetEnd(graph()->NewNode(common()->End(), merge));
+ Optimize();
+ Capture<Node*> branch1_capture, branch2_capture;
+ EXPECT_THAT(
+ end(),
+ IsEnd(IsMerge(IsMerge(IsIfTrue(CaptureEq(&branch1_capture)),
+ IsIfTrue(CaptureEq(&branch2_capture))),
+ IsMerge(IsIfFalse(AllOf(CaptureEq(&branch1_capture),
+ IsBranch(cond1, control1))),
+ IsIfFalse(AllOf(CaptureEq(&branch2_capture),
+ IsBranch(cond2, control2)))))));
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « test/mjsunit/asm/if-cloning.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698