Skip to content

Commit 7c41341

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b708aea0bc71' from llvm.org/release/21.x into stable/21.x
2 parents 198cf83 + b708aea commit 7c41341

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15093,15 +15093,20 @@ void SCEVUnionPredicate::add(const SCEVPredicate *N, ScalarEvolution &SE) {
1509315093
return;
1509415094
}
1509515095

15096+
// Implication checks are quadratic in the number of predicates. Stop doing
15097+
// them if there are many predicates, as they should be too expensive to use
15098+
// anyway at that point.
15099+
bool CheckImplies = Preds.size() < 16;
15100+
1509615101
// Only add predicate if it is not already implied by this union predicate.
15097-
if (implies(N, SE))
15102+
if (CheckImplies && implies(N, SE))
1509815103
return;
1509915104

1510015105
// Build a new vector containing the current predicates, except the ones that
1510115106
// are implied by the new predicate N.
1510215107
SmallVector<const SCEVPredicate *> PrunedPreds;
1510315108
for (auto *P : Preds) {
15104-
if (N->implies(P, SE))
15109+
if (CheckImplies && N->implies(P, SE))
1510515110
continue;
1510615111
PrunedPreds.push_back(P);
1510715112
}

0 commit comments

Comments
 (0)