Reviewers: jarin,

Description:
Fix scheduler for floating non-naked non-empty loops.

[email protected]
TEST=cctest/test-scheduler/NestedFloatingDiamondWithLoop

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

Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+29, -6 lines):
  M src/compiler/scheduler.cc
  M test/cctest/compiler/test-scheduler.cc


Index: src/compiler/scheduler.cc
diff --git a/src/compiler/scheduler.cc b/src/compiler/scheduler.cc
index a0cf11235a50b11d218bc09e486115e02e9819bb..54b8c89725c8a7622de495326959ce03d2545a81 100644
--- a/src/compiler/scheduler.cc
+++ b/src/compiler/scheduler.cc
@@ -296,6 +296,9 @@ class CFGBuilder {
   }

  private:
+  // TODO(mstarzinger): Only for Scheduler::FuseFloatingControl.
+  friend class Scheduler;
+
   void FixNode(BasicBlock* block, Node* node) {
     schedule_->AddNode(block, node);
     scheduler_->UpdatePlacement(node, Scheduler::kFixed);
@@ -1163,7 +1166,6 @@ class ScheduleEarlyNodeVisitor {

     // Fixed nodes already know their schedule early position.
     if (scheduler_->GetPlacement(node) == Scheduler::kFixed) {
-      DCHECK_EQ(schedule_->start(), data->minimum_block_);
       data->minimum_block_ = schedule_->block(node);
       Trace("Fixing #%d:%s minimum_block = B%d, dominator_depth = %d\n",
             node->id(), node->op()->mnemonic(),
@@ -1455,6 +1457,29 @@ void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) {
   }
   GenerateImmediateDominatorTree();

+  // Iterate on phase 4: Schedule nodes early.
+ // TODO(mstarzinger): The following loop gathering the propagation roots is a + // temporary solution and should be merged into the rest of the scheduler as
+  // soon as the approach settled for all floating loops.
+  NodeVector propagation_roots(cfg_builder.control_);
+  for (Node* node : cfg_builder.control_) {
+    for (Node* use : node->uses()) {
+      if (use->opcode() == IrOpcode::kPhi ||
+          use->opcode() == IrOpcode::kEffectPhi) {
+        propagation_roots.push_back(use);
+      }
+    }
+  }
+  if (FLAG_trace_turbo_scheduler) {
+    Trace("propagation roots: ");
+    for (Node* node : propagation_roots) {
+      Trace("#%d:%s ", node->id(), node->op()->mnemonic());
+    }
+    Trace("\n");
+  }
+  ScheduleEarlyNodeVisitor schedule_early_visitor(zone_, this);
+  schedule_early_visitor.Run(&propagation_roots);
+
   // Move previously planned nodes.
   // TODO(mstarzinger): Improve that by supporting bulk moves.
   scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_));
Index: test/cctest/compiler/test-scheduler.cc
diff --git a/test/cctest/compiler/test-scheduler.cc b/test/cctest/compiler/test-scheduler.cc index 659aacd78df45c59c7c00adfeda5b5980f8e31d8..62971a54181e5f10df22b5b1c2971439db72dbe9 100644
--- a/test/cctest/compiler/test-scheduler.cc
+++ b/test/cctest/compiler/test-scheduler.cc
@@ -1836,10 +1836,8 @@ TEST(NestedFloatingDiamondWithLoop) {
   Node* loop = graph.NewNode(common.Loop(2), f, start);
   Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop);

-  // TODO(mstarzinger): Make scheduler deal with non-empty loops here.
-  // Node* add = graph.NewNode(machine.IntAdd(), ind, fv);
-
-  Node* br1 = graph.NewNode(common.Branch(), ind, loop);
+  Node* add = graph.NewNode(machine.IntAdd(), ind, fv);
+  Node* br1 = graph.NewNode(common.Branch(), add, loop);
   Node* t1 = graph.NewNode(common.IfTrue(), br1);
   Node* f1 = graph.NewNode(common.IfFalse(), br1);

@@ -1854,7 +1852,7 @@ TEST(NestedFloatingDiamondWithLoop) {

   graph.SetEnd(end);

-  ComputeAndVerifySchedule(19, &graph);
+  ComputeAndVerifySchedule(20, &graph);
 }




--
--
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