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

Unified Diff: test/unittests/compiler/loop-peeling-unittest.cc

Issue 1052753004: [turbofan] Rework handling of loop exits in loop peeling. (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/loop-peeling.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/loop-peeling-unittest.cc
diff --git a/test/unittests/compiler/loop-peeling-unittest.cc b/test/unittests/compiler/loop-peeling-unittest.cc
index dd0c46c42a813f3dfbb8a4aa7c22aad10d5b4a1d..61b527ca13316be33288f9e30e5a2d3b1d9ed4e3 100644
--- a/test/unittests/compiler/loop-peeling-unittest.cc
+++ b/test/unittests/compiler/loop-peeling-unittest.cc
@@ -71,10 +71,13 @@ class LoopPeelingTest : public GraphTest {
PeeledIteration* PeelOne() {
LoopTree* loop_tree = GetLoopTree();
- return Peel(loop_tree, loop_tree->outer_loops()[0]);
+ LoopTree::Loop* loop = loop_tree->outer_loops()[0];
+ EXPECT_TRUE(LoopPeeler::CanPeel(loop_tree, loop));
+ return Peel(loop_tree, loop);
}
PeeledIteration* Peel(LoopTree* loop_tree, LoopTree::Loop* loop) {
+ EXPECT_TRUE(LoopPeeler::CanPeel(loop_tree, loop));
PeeledIteration* peeled =
LoopPeeler::Peel(graph(), common(), loop_tree, loop, zone());
if (FLAG_trace_turbo_graph) {
@@ -446,6 +449,49 @@ TEST_F(LoopPeelingTest, TwoBackedgeLoopWithCounter) {
}
+TEST_F(LoopPeelingTest, TwoExitLoop_nope) {
+ Node* p0 = Parameter(0);
+ Node* loop = graph()->NewNode(common()->Loop(2), start(), start());
+ Branch b1 = NewBranch(p0, loop);
+ Branch b2 = NewBranch(p0, b1.if_true);
+
+ loop->ReplaceInput(1, b2.if_true);
+ Node* merge = graph()->NewNode(common()->Merge(2), b1.if_false, b2.if_false);
+ InsertReturn(p0, start(), merge);
+
+ {
+ LoopTree* loop_tree = GetLoopTree();
+ LoopTree::Loop* loop = loop_tree->outer_loops()[0];
+ EXPECT_FALSE(LoopPeeler::CanPeel(loop_tree, loop));
+ }
+}
+
+
+const Operator kMockCall(IrOpcode::kCall, Operator::kNoProperties, "MockCall",
+ 0, 0, 1, 1, 0, 2);
+
+
+TEST_F(LoopPeelingTest, TwoExitLoopWithCall_nope) {
+ Node* p0 = Parameter(0);
+ Node* loop = graph()->NewNode(common()->Loop(2), start(), start());
+ Branch b1 = NewBranch(p0, loop);
+
+ Node* call = graph()->NewNode(&kMockCall, b1.if_true);
+ Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
+ Node* if_exception = graph()->NewNode(common()->IfException(), call);
+
+ loop->ReplaceInput(1, if_success);
+ Node* merge = graph()->NewNode(common()->Merge(2), b1.if_false, if_exception);
+ InsertReturn(p0, start(), merge);
+
+ {
+ LoopTree* loop_tree = GetLoopTree();
+ LoopTree::Loop* loop = loop_tree->outer_loops()[0];
+ EXPECT_FALSE(LoopPeeler::CanPeel(loop_tree, loop));
+ }
+}
+
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « src/compiler/loop-peeling.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698