Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Allow nested loops with shared entry
Browse files Browse the repository at this point in the history
Predecessors which `entry` dominates need not be considered
side-entries.
  • Loading branch information
JosephTremoulet committed Aug 17, 2017
1 parent 2feecd6 commit 1091e89
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,10 +1880,24 @@ class LoopSearch
if ((testNum < top->bbNum) || (testNum > bottom->bbNum))
{
// Pred is out of loop range
if ((pred == head) && (block == entry))
if (block == entry)
{
// This is the single entry we expect.
continue;
if (pred == head)
{
// This is the single entry we expect.
continue;
}
// ENTRY has some pred other than head outside the loop. If ENTRY does not
// dominate this pred, we'll consider this a side-entry and skip this loop;
// otherwise the loop is still valid and this may be a (flow-wise) back-edge
// of an outer loop. For the dominance test, if `pred` is a new block, use
// its unique predecessor since the dominator tree has info for that.
BasicBlock* effectivePred = (pred->bbNum > oldBlockMaxNum ? pred->bbPrev : pred);
if (comp->fgDominate(entry, effectivePred))
{
// Outer loop back-edge
continue;
}
}

// There are multiple entries to this loop, don't consider it.
Expand Down

0 comments on commit 1091e89

Please sign in to comment.