Make scheduler handle floating non-naked loops.

R=jarin@chromium.org
TEST=cctest/test-scheduler/NestedFloatingDiamondWithLoop

Review URL: https://codereview.chromium.org/706123003

Cr-Commit-Position: refs/heads/master@{#25217}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25217 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1d0c7f16
......@@ -685,7 +685,7 @@ class SpecialRPONumberer : public ZoneObject {
stack_.resize(schedule_->BasicBlockCount() - previous_block_count_);
previous_block_count_ = schedule_->BasicBlockCount();
int stack_depth = Push(stack_, 0, entry, kBlockUnvisited1);
int num_loops = 0;
int num_loops = static_cast<int>(loops_.size());
while (stack_depth > 0) {
int current = stack_depth - 1;
......@@ -717,7 +717,7 @@ class SpecialRPONumberer : public ZoneObject {
}
// If no loops were encountered, then the order we computed was correct.
if (num_loops != 0) {
if (num_loops > static_cast<int>(loops_.size())) {
// Otherwise, compute the loop information from the backedges in order
// to perform a traversal that groups loop bodies together.
ComputeLoopInfo(stack_, num_loops, &backedges_);
......@@ -725,7 +725,7 @@ class SpecialRPONumberer : public ZoneObject {
// Initialize the "loop stack". Note the entry could be a loop header.
LoopInfo* loop =
HasLoopNumber(entry) ? &loops_[GetLoopNumber(entry)] : NULL;
order = NULL;
order = insert_after;
// Perform an iterative post-order traversal, visiting loop bodies before
// edges that lead out of loops. Visits each block once, but linking loop
......@@ -737,7 +737,7 @@ class SpecialRPONumberer : public ZoneObject {
BasicBlock* block = frame->block;
BasicBlock* succ = NULL;
if (frame->index < block->SuccessorCount()) {
if (block != end && frame->index < block->SuccessorCount()) {
// Process the next normal successor.
succ = block->SuccessorAt(frame->index++);
} else if (HasLoopNumber(block)) {
......
......@@ -1816,6 +1816,48 @@ TEST(NestedFloatingDiamonds) {
}
TEST(NestedFloatingDiamondWithLoop) {
HandleAndZoneScope scope;
Graph graph(scope.main_zone());
CommonOperatorBuilder common(scope.main_zone());
SimplifiedOperatorBuilder simplified(scope.main_zone());
MachineOperatorBuilder machine;
Node* start = graph.NewNode(common.Start(2));
graph.SetStart(start);
Node* p0 = graph.NewNode(common.Parameter(0), start);
Node* fv = graph.NewNode(common.Int32Constant(7));
Node* br = graph.NewNode(common.Branch(), p0, graph.start());
Node* t = graph.NewNode(common.IfTrue(), br);
Node* f = graph.NewNode(common.IfFalse(), br);
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* t1 = graph.NewNode(common.IfTrue(), br1);
Node* f1 = graph.NewNode(common.IfFalse(), br1);
loop->ReplaceInput(1, t1); // close loop.
ind->ReplaceInput(1, ind); // close induction variable.
Node* m = graph.NewNode(common.Merge(2), t, f1);
Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), fv, ind, m);
Node* ret = graph.NewNode(common.Return(), phi, start, start);
Node* end = graph.NewNode(common.End(), ret, start);
graph.SetEnd(end);
ComputeAndVerifySchedule(19, &graph);
}
TEST(LoopedFloatingDiamond1) {
HandleAndZoneScope scope;
Graph graph(scope.main_zone());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment