[polly] [polly] Use *Set::insert_range (NFC) (PR #133609)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 29 19:07:52 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/133609

None

>From 6084942be528451511917b86d27fd84f97755db5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 29 Mar 2025 19:00:08 -0700
Subject: [PATCH] [polly] Use *Set::insert_range (NFC)

---
 polly/lib/Analysis/ScopBuilder.cpp             | 9 +++------
 polly/lib/Analysis/ScopDetection.cpp           | 2 +-
 polly/lib/CodeGen/IslNodeBuilder.cpp           | 3 +--
 polly/lib/Support/SCEVValidator.cpp            | 4 ++--
 polly/lib/Transform/MaximalStaticExpansion.cpp | 8 +++-----
 5 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp
index 76c9b4775784e..351eab7f93710 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -2633,8 +2633,7 @@ void ScopBuilder::checkForReductions(ScopStmt &Stmt) {
         if (auto *Ptr = dyn_cast<Instruction>(Load->getPointerOperand())) {
           const auto &It = State.find(Ptr);
           if (It != State.end())
-            for (const auto &FlowInSetElem : It->second)
-              InvalidLoads.insert(FlowInSetElem.first);
+            InvalidLoads.insert_range(llvm::make_first_range(It->second));
         }
 
         // If this load is used outside this stmt, invalidate it.
@@ -2654,8 +2653,7 @@ void ScopBuilder::checkForReductions(ScopStmt &Stmt) {
                 dyn_cast<Instruction>(Store->getPointerOperand())) {
           const auto &It = State.find(Ptr);
           if (It != State.end())
-            for (const auto &FlowInSetElem : It->second)
-              InvalidLoads.insert(FlowInSetElem.first);
+            InvalidLoads.insert_range(llvm::make_first_range(It->second));
         }
 
         // Propagate the uses of the value operand to the store
@@ -2710,8 +2708,7 @@ void ScopBuilder::checkForReductions(ScopStmt &Stmt) {
       // If this operation is used outside the stmt, invalidate all the loads
       // which feed into it.
       if (UsedOutsideStmt)
-        for (const auto &FlowInSetElem : InstInFlowSet)
-          InvalidLoads.insert(FlowInSetElem.first);
+        InvalidLoads.insert_range(llvm::make_first_range(InstInFlowSet));
     }
   }
 
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 7ad2e53b589ae..260211bdce31f 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -500,7 +500,7 @@ bool ScopDetection::onlyValidRequiredInvariantLoads(
     }
   }
 
-  Context.RequiredILS.insert(RequiredILS.begin(), RequiredILS.end());
+  Context.RequiredILS.insert_range(RequiredILS);
 
   return true;
 }
diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp
index 6affc202d0a4c..ca497927e2976 100644
--- a/polly/lib/CodeGen/IslNodeBuilder.cpp
+++ b/polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -325,8 +325,7 @@ void IslNodeBuilder::getReferencesInSubtree(const isl::ast_node &For,
   SubtreeReferences References = {
       LI, SE, S, ValueMap, Values, SCEVs, getBlockGenerator(), nullptr};
 
-  for (const auto &I : IDToValue)
-    Values.insert(I.second);
+  Values.insert_range(llvm::make_second_range(IDToValue));
 
   // NOTE: this is populated in IslNodeBuilder::addParameters
   for (const auto &I : OutsideLoopIterations)
diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp
index 599d7f9d60802..ad3d0c22295b5 100644
--- a/polly/lib/Support/SCEVValidator.cpp
+++ b/polly/lib/Support/SCEVValidator.cpp
@@ -83,7 +83,7 @@ class ValidatorResult final {
 
   /// Add the parameters of Source to this result.
   void addParamsFrom(const ValidatorResult &Source) {
-    Parameters.insert(Source.Parameters.begin(), Source.Parameters.end());
+    Parameters.insert_range(Source.Parameters);
   }
 
   /// Merge a result.
@@ -633,7 +633,7 @@ static bool isAffineExpr(Value *V, const Region *R, Loop *Scope,
     return false;
 
   auto ResultParams = Result.getParameters();
-  Params.insert(ResultParams.begin(), ResultParams.end());
+  Params.insert_range(ResultParams);
 
   return true;
 }
diff --git a/polly/lib/Transform/MaximalStaticExpansion.cpp b/polly/lib/Transform/MaximalStaticExpansion.cpp
index c9227ac0bfd10..0719840f74a79 100644
--- a/polly/lib/Transform/MaximalStaticExpansion.cpp
+++ b/polly/lib/Transform/MaximalStaticExpansion.cpp
@@ -139,8 +139,7 @@ class MaximalStaticExpansionImpl {
                     SmallPtrSetImpl<MemoryAccess *> &Reads, Scop &S) {
     if (SAI->isValueKind()) {
       Writes.insert(S.getValueDef(SAI));
-      for (auto MA : S.getValueUses(SAI))
-        Reads.insert(MA);
+      Reads.insert_range(S.getValueUses(SAI));
       return true;
     } else if (SAI->isPHIKind()) {
       auto Read = S.getPHIRead(SAI);
@@ -399,9 +398,8 @@ class MaximalStaticExpansionImpl {
   /// @param Dependences The RAW dependences of the SCop.
   void expandPhi(Scop &S, const ScopArrayInfo *SAI,
                  const isl::union_map &Dependences) {
-    SmallPtrSet<MemoryAccess *, 4> Writes;
-    for (auto MA : S.getPHIIncomings(SAI))
-      Writes.insert(MA);
+    SmallPtrSet<MemoryAccess *, 4> Writes(llvm::from_range,
+                                          S.getPHIIncomings(SAI));
     auto Read = S.getPHIRead(SAI);
     auto ExpandedSAI = expandAccess(Read);
 



More information about the llvm-commits mailing list