aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorDavid Sherwood <david.sherwood@arm.com>2024-09-17 10:28:24 +0100
committerGitHub <noreply@github.com>2024-09-17 10:28:24 +0100
commit270ee6549c9368b2ff86ef9794a7fd5e5496ef00 (patch)
tree7554d65abe14edda1c5d23a22fdb9771a85f6e1a /llvm/lib/Analysis/ScalarEvolution.cpp
parent1e64864c6fdcbd9cb78b69b1a3a3f3da84ec2e7a (diff)
downloadllvm-270ee6549c9368b2ff86ef9794a7fd5e5496ef00.zip
llvm-270ee6549c9368b2ff86ef9794a7fd5e5496ef00.tar.gz
llvm-270ee6549c9368b2ff86ef9794a7fd5e5496ef00.tar.bz2
[Analysis][NFC] Clean-up in ScalarEvolution when copying predicates (#108851)
There are a few places in ScalarEvolution.cpp where we copy predicates from one list to another and they have a similar pattern: for (const auto *P : ENT.Predicates) Predicates->push_back(P); We can avoid the loop by writing them like this: Predicates->append(ENT.Predicates.begin(), ENT.Predicates.end()); which may end up being more efficient since we only have to try reserving more space once.
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 57e03f6..e06863b 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -8594,8 +8594,7 @@ const SCEV *ScalarEvolution::BackedgeTakenInfo::getExact(
Ops.push_back(BECount);
if (Preds)
- for (const auto *P : ENT.Predicates)
- Preds->push_back(P);
+ append_range(*Preds, ENT.Predicates);
assert((Preds || ENT.hasAlwaysTruePredicate()) &&
"Predicate should be always true!");
@@ -8616,8 +8615,7 @@ ScalarEvolution::BackedgeTakenInfo::getExitNotTaken(
if (ENT.hasAlwaysTruePredicate())
return &ENT;
else if (Predicates) {
- for (const auto *P : ENT.Predicates)
- Predicates->push_back(P);
+ append_range(*Predicates, ENT.Predicates);
return &ENT;
}
}
@@ -8659,8 +8657,7 @@ const SCEV *ScalarEvolution::BackedgeTakenInfo::getSymbolicMax(
"dominate latch!");
ExitCounts.push_back(ExitCount);
if (Predicates)
- for (const auto *P : ENT.Predicates)
- Predicates->push_back(P);
+ append_range(*Predicates, ENT.Predicates);
assert((Predicates || ENT.hasAlwaysTruePredicate()) &&
"Predicate should be always true!");
@@ -14804,8 +14801,7 @@ const SCEVAddRecExpr *ScalarEvolution::convertSCEVToAddRecWithPredicates(
// Since the transformation was successful, we can now transfer the SCEV
// predicates.
- for (const auto *P : TransformPreds)
- Preds.insert(P);
+ Preds.insert(TransformPreds.begin(), TransformPreds.end());
return AddRec;
}