[llvm] [SCEV] Fix exit condition for recursive loop guard collection (PR #120442)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 19 08:31:01 PST 2024
================
@@ -15767,7 +15768,7 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
// If we are recursively collecting guards stop after 2
// predecessors to limit compile-time impact for now.
- if (Depth > 0 && Terms.size() == 2)
+ if (Depth > 0 && ++NumCollectedConditions == 2)
----------------
fhahn wrote:
Ah I see, the issue is when we have cases where `Terms` already has entries from assumes.
```suggestion
++ NumPredecessors;
if (Depth > 0 && NumVisitedPredecessors == 2)
```
This aligns better with the comment immediately above. Might also be worth pulling out the increment of the condition to simplify for the reader
https://github.com/llvm/llvm-project/pull/120442
More information about the llvm-commits
mailing list