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

Commit

Permalink
Record doomed loops iff COUNT_LOOPS defined
Browse files Browse the repository at this point in the history
When COUNT_LOOPS is not defined, stop earlier to avoid wasting time
finding a loop we won't be able to record.
When COUNT_LOOPS is defined, don't stop at all, so we can count all the
loops.
  • Loading branch information
JosephTremoulet committed Aug 17, 2017
1 parent 8a7fd15 commit 2feecd6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2409,11 +2409,9 @@ void Compiler::optFindNaturalLoops()
if (search.findLoop(head))
{
// Found a loop; record it and see if we've hit the limit.
if (!search.recordLoop())
{
// We hit the limit.
break;
}
bool recordedLoop = search.recordLoop();

(recordedLoop); // avoid unusued variable warnings in COUNT_LOOPS and !DEBUG

#if COUNT_LOOPS
if (!hasMethodLoops)
Expand All @@ -2429,6 +2427,13 @@ void Compiler::optFindNaturalLoops()

/* keep track of the number of exits */
loopExitCountTable.record(static_cast<unsigned>(exitCount));
#else // COUNT_LOOPS
assert(recordedLoop);
if (optLoopCount == MAX_LOOP_NUM)
{
// We won't be able to record any more loops, so stop looking.
break;
}
#endif // COUNT_LOOPS
}
}
Expand Down

0 comments on commit 2feecd6

Please sign in to comment.