[llvm] [Analysis][NFC] Use SmallVectorImpl consistently in ScalarEvolution (PR #105663)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 22 07:12:43 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: David Sherwood (david-arm)
<details>
<summary>Changes</summary>
Use SmallVectorImpl instead of SmallVector for function arguments
to give the caller greater flexibility in choice of initial size.
---
Full diff: https://github.com/llvm/llvm-project/pull/105663.diff
2 Files Affected:
- (modified) llvm/include/llvm/Analysis/ScalarEvolution.h (+9-8)
- (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+7-8)
``````````diff
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 5154e2f6659c12..fe46a504bce5d1 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -887,8 +887,8 @@ class ScalarEvolution {
/// SCEV predicates to Predicates that are required to be true in order for
/// the answer to be correct. Predicates can be checked with run-time
/// checks and can be used to perform loop versioning.
- const SCEV *getPredicatedBackedgeTakenCount(const Loop *L,
- SmallVector<const SCEVPredicate *, 4> &Predicates);
+ const SCEV *getPredicatedBackedgeTakenCount(
+ const Loop *L, SmallVectorImpl<const SCEVPredicate *> &Predicates);
/// When successful, this returns a SCEVConstant that is greater than or equal
/// to (i.e. a "conservative over-approximation") of the value returend by
@@ -911,7 +911,7 @@ class ScalarEvolution {
/// the answer to be correct. Predicates can be checked with run-time
/// checks and can be used to perform loop versioning.
const SCEV *getPredicatedSymbolicMaxBackedgeTakenCount(
- const Loop *L, SmallVector<const SCEVPredicate *, 4> &Predicates);
+ const Loop *L, SmallVectorImpl<const SCEVPredicate *> &Predicates);
/// Return true if the backedge taken count is either the value returned by
/// getConstantMaxBackedgeTakenCount or zero.
@@ -1556,8 +1556,9 @@ class ScalarEvolution {
/// If we allowed SCEV predicates to be generated when populating this
/// vector, this information can contain them and therefore a
/// SCEVPredicate argument should be added to getExact.
- const SCEV *getExact(const Loop *L, ScalarEvolution *SE,
- SmallVector<const SCEVPredicate *, 4> *Predicates = nullptr) const;
+ const SCEV *getExact(
+ const Loop *L, ScalarEvolution *SE,
+ SmallVectorImpl<const SCEVPredicate *> *Predicates = nullptr) const;
/// Return the number of times this loop exit may fall through to the back
/// edge, or SCEVCouldNotCompute. The loop is guaranteed not to exit via
@@ -1574,9 +1575,9 @@ class ScalarEvolution {
ScalarEvolution *SE) const;
/// Get the symbolic max backedge taken count for the loop.
- const SCEV *
- getSymbolicMax(const Loop *L, ScalarEvolution *SE,
- SmallVector<const SCEVPredicate *, 4> *Predicates = nullptr);
+ const SCEV *getSymbolicMax(
+ const Loop *L, ScalarEvolution *SE,
+ SmallVectorImpl<const SCEVPredicate *> *Predicates = nullptr);
/// Get the symbolic max backedge taken count for the particular loop exit.
const SCEV *getSymbolicMax(const BasicBlock *ExitingBlock,
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index a19358dee8ef49..206630e65db025 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -8249,9 +8249,8 @@ const SCEV *ScalarEvolution::getExitCount(const Loop *L,
llvm_unreachable("Invalid ExitCountKind!");
}
-const SCEV *
-ScalarEvolution::getPredicatedBackedgeTakenCount(const Loop *L,
- SmallVector<const SCEVPredicate *, 4> &Preds) {
+const SCEV *ScalarEvolution::getPredicatedBackedgeTakenCount(
+ const Loop *L, SmallVectorImpl<const SCEVPredicate *> &Preds) {
return getPredicatedBackedgeTakenInfo(L).getExact(L, this, &Preds);
}
@@ -8269,7 +8268,7 @@ const SCEV *ScalarEvolution::getBackedgeTakenCount(const Loop *L,
}
const SCEV *ScalarEvolution::getPredicatedSymbolicMaxBackedgeTakenCount(
- const Loop *L, SmallVector<const SCEVPredicate *, 4> &Preds) {
+ const Loop *L, SmallVectorImpl<const SCEVPredicate *> &Preds) {
return getPredicatedBackedgeTakenInfo(L).getSymbolicMax(L, this, &Preds);
}
@@ -8539,9 +8538,9 @@ void ScalarEvolution::forgetBlockAndLoopDispositions(Value *V) {
/// is never skipped. This is a valid assumption as long as the loop exits via
/// that test. For precise results, it is the caller's responsibility to specify
/// the relevant loop exiting block using getExact(ExitingBlock, SE).
-const SCEV *
-ScalarEvolution::BackedgeTakenInfo::getExact(const Loop *L, ScalarEvolution *SE,
- SmallVector<const SCEVPredicate *, 4> *Preds) const {
+const SCEV *ScalarEvolution::BackedgeTakenInfo::getExact(
+ const Loop *L, ScalarEvolution *SE,
+ SmallVectorImpl<const SCEVPredicate *> *Preds) const {
// If any exits were not computable, the loop is not computable.
if (!isComplete() || ExitNotTaken.empty())
return SE->getCouldNotCompute();
@@ -8624,7 +8623,7 @@ ScalarEvolution::BackedgeTakenInfo::getConstantMax(ScalarEvolution *SE) const {
const SCEV *ScalarEvolution::BackedgeTakenInfo::getSymbolicMax(
const Loop *L, ScalarEvolution *SE,
- SmallVector<const SCEVPredicate *, 4> *Predicates) {
+ SmallVectorImpl<const SCEVPredicate *> *Predicates) {
if (!SymbolicMax) {
// Form an expression for the maximum exit count possible for this loop. We
// merge the max and exact information to approximate a version of
``````````
</details>
https://github.com/llvm/llvm-project/pull/105663
More information about the llvm-commits
mailing list