Reviewers: Michael Starzinger,

Description:
[turbofan] Fix loop analysis bug with certain phi structures.

[email protected]
BUG=

Please review this at https://codereview.chromium.org/909463002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+39, -0 lines):
  M src/compiler/loop-analysis.cc
  M test/cctest/compiler/test-loop-analysis.cc


Index: src/compiler/loop-analysis.cc
diff --git a/src/compiler/loop-analysis.cc b/src/compiler/loop-analysis.cc
index 38406f83917523ecc9221b1a5b917ad2fca3742a..2a1487136971530e78f88aa43741f7b2a3afbe5a 100644
--- a/src/compiler/loop-analysis.cc
+++ b/src/compiler/loop-analysis.cc
@@ -235,6 +235,7 @@ class LoopFinderImpl {
     // Setup loop mark for phis attached to loop header.
     for (Node* use : node->uses()) {
       if (NodeProperties::IsPhi(use)) {
+        info(use);  // create the NodeInfo
         SetBackwardMark(use, loop_num);
         loop_tree_->node_to_loop_num_[use->id()] = loop_num;
       }
Index: test/cctest/compiler/test-loop-analysis.cc
diff --git a/test/cctest/compiler/test-loop-analysis.cc b/test/cctest/compiler/test-loop-analysis.cc index 87746ecf21e5abfe25a39bf271bab9a28cef43d3..06682ef5a9590632159cb059e38b9c0b0bab3bf0 100644
--- a/test/cctest/compiler/test-loop-analysis.cc
+++ b/test/cctest/compiler/test-loop-analysis.cc
@@ -470,6 +470,41 @@ TEST(LaNestedLoop1c) {
 }


+TEST(LaNestedLoop1x) {
+  // One loop nested in another.
+  LoopFinderTester t;
+  While w1(t, t.p0);
+  While w2(t, t.p0);
+  w2.nest(w1);
+
+  const Operator* op = t.common.Phi(kMachInt32, 2);
+  Node* p1a = t.graph.NewNode(op, t.p0, t.p0, w1.loop);
+  Node* p1b = t.graph.NewNode(op, t.p0, t.p0, w1.loop);
+  Node* p2a = t.graph.NewNode(op, p1a, t.p0, w2.loop);
+  Node* p2b = t.graph.NewNode(op, p1b, t.p0, w2.loop);
+
+  p1a->ReplaceInput(1, p2b);
+  p1b->ReplaceInput(1, p2a);
+
+  p2a->ReplaceInput(1, p2b);
+  p2b->ReplaceInput(1, p2a);
+
+  t.Return(t.p0, p1a, w1.exit);
+
+  Node* chain[] = {w1.loop, w2.loop};
+  t.CheckNestedLoops(chain, 2);
+
+  Node* h1[] = {w1.loop, p1a, p1b};
+  Node* b1[] = {w1.branch, w1.if_true, w2.loop,    p2a,
+                p2b,       w2.branch,  w2.if_true, w2.exit};
+  t.CheckLoop(h1, 3, b1, 8);
+
+  Node* h2[] = {w2.loop, p2a, p2b};
+  Node* b2[] = {w2.branch, w2.if_true};
+  t.CheckLoop(h2, 3, b2, 2);
+}
+
+
 TEST(LaNestedLoop2) {
   // Two loops nested in an outer loop.
   LoopFinderTester t;
@@ -975,3 +1010,6 @@ TEST(LaManyNested_34) { RunManyNestedLoops_i(34); }
 TEST(LaManyNested_62) { RunManyNestedLoops_i(62); }
 TEST(LaManyNested_63) { RunManyNestedLoops_i(63); }
 TEST(LaManyNested_64) { RunManyNestedLoops_i(64); }
+
+
+TEST(LaPhiTangle) { LoopFinderTester t; }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to