Skip to content

Commit 057a47a

Browse files
committed
[SCEV] Fix exit condition for recursive loop guard collection
When assumptions are present Terms.size() does not actually count the number of conditions collected from dominating branches; introduce a separate counter.
1 parent 76714be commit 057a47a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15753,6 +15753,7 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
1575315753
// predecessors that can be found that have unique successors leading to the
1575415754
// original header.
1575515755
// TODO: share this logic with isLoopEntryGuardedByCond.
15756+
unsigned NumCollectedConditions = 0;
1575615757
std::pair<const BasicBlock *, const BasicBlock *> Pair(Pred, Block);
1575715758
for (; Pair.first;
1575815759
Pair = SE.getPredecessorWithUniqueSuccessorForBB(Pair.first)) {
@@ -15767,7 +15768,7 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
1576715768

1576815769
// If we are recursively collecting guards stop after 2
1576915770
// predecessors to limit compile-time impact for now.
15770-
if (Depth > 0 && Terms.size() == 2)
15771+
if (Depth > 0 && ++NumCollectedConditions == 2)
1577115772
break;
1577215773
}
1577315774
// Finally, if we stopped climbing the predecessor chain because

0 commit comments

Comments
 (0)