-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Transforms] Use range constructors of *Set (NFC) #133203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_set_use_ctor_from_range_llvm_Transforms
Mar 27, 2025
Merged
[Transforms] Use range constructors of *Set (NFC) #133203
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_set_use_ctor_from_range_llvm_Transforms
Mar 27, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-vectorizers Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/133203.diff 15 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/ExtractGV.cpp b/llvm/lib/Transforms/IPO/ExtractGV.cpp
index 7b37453611032..16fdb93e2b21b 100644
--- a/llvm/lib/Transforms/IPO/ExtractGV.cpp
+++ b/llvm/lib/Transforms/IPO/ExtractGV.cpp
@@ -52,7 +52,7 @@ static void makeVisible(GlobalValue &GV, bool Delete) {
/// global values specified.
ExtractGVPass::ExtractGVPass(std::vector<GlobalValue *> &GVs, bool deleteS,
bool keepConstInit)
- : Named(GVs.begin(), GVs.end()), deleteStuff(deleteS),
+ : Named(llvm::from_range, GVs), deleteStuff(deleteS),
keepConstInit(keepConstInit) {}
PreservedAnalyses ExtractGVPass::run(Module &M, ModuleAnalysisManager &) {
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 2d046f09f1b2b..83cc1e5f04f3d 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2319,10 +2319,10 @@ class LLVMUsed {
LLVMUsed(Module &M) {
SmallVector<GlobalValue *, 4> Vec;
UsedV = collectUsedGlobalVariables(M, Vec, false);
- Used = {Vec.begin(), Vec.end()};
+ Used = {llvm::from_range, Vec};
Vec.clear();
CompilerUsedV = collectUsedGlobalVariables(M, Vec, true);
- CompilerUsed = {Vec.begin(), Vec.end()};
+ CompilerUsed = {llvm::from_range, Vec};
}
using iterator = SmallPtrSet<GlobalValue *, 4>::iterator;
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 29bf214a5c9e7..82c3d9dbb3fc3 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -5874,7 +5874,7 @@ PreservedAnalyses OpenMPOptCGSCCPass::run(LazyCallGraph::SCC &C,
bool PostLink = LTOPhase == ThinOrFullLTOPhase::FullLTOPostLink ||
LTOPhase == ThinOrFullLTOPhase::ThinLTOPostLink ||
LTOPhase == ThinOrFullLTOPhase::ThinLTOPreLink;
- SetVector<Function *> Functions(SCC.begin(), SCC.end());
+ SetVector<Function *> Functions(llvm::from_range, SCC);
OMPInformationCache InfoCache(*(Functions.back()->getParent()), AG, Allocator,
/*CGSCC*/ &Functions, PostLink);
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index b41899a2dff66..93b629d531ad8 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1591,8 +1591,7 @@ bool GVNPass::PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
// that we only have to insert *one* load (which means we're basically moving
// the load, not inserting a new one).
- SmallPtrSet<BasicBlock *, 4> Blockers(UnavailableBlocks.begin(),
- UnavailableBlocks.end());
+ SmallPtrSet<BasicBlock *, 4> Blockers(llvm::from_range, UnavailableBlocks);
// Let's find the first basic block with more than one predecessor. Walk
// backwards through predecessors if needed.
diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index 24d7f9381c045..d0f844d7cd36a 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -522,7 +522,7 @@ class GVNSink {
unsigned NumSunk = 0;
ReversePostOrderTraversal<Function*> RPOT(&F);
- VN.setReachableBBs(BasicBlocksSet(RPOT.begin(), RPOT.end()));
+ VN.setReachableBBs(BasicBlocksSet(llvm::from_range, RPOT));
// Populate reverse post-order to order basic blocks in deterministic
// order. Any arbitrary ordering will work in this case as long as they are
// deterministic. The node ordering of newly created basic blocks
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index 798498292f381..73a3f5e4d3694 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -895,7 +895,7 @@ void InferAddressSpacesImpl::inferAddressSpaces(
ArrayRef<WeakTrackingVH> Postorder,
ValueToAddrSpaceMapTy &InferredAddrSpace,
PredicatedAddrSpaceMapTy &PredicatedAS) const {
- SetVector<Value *> Worklist(Postorder.begin(), Postorder.end());
+ SetVector<Value *> Worklist(llvm::from_range, Postorder);
// Initially, all expressions are in the uninitialized address space.
for (Value *V : Postorder)
InferredAddrSpace[V] = UninitializedAddressSpace;
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 39f72703bd46e..d872a381050ca 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1564,8 +1564,7 @@ static void splitPredecessorsOfLoopExit(PHINode *PN, DominatorTree *DT,
#ifndef NDEBUG
SmallVector<BasicBlock *, 32> ExitBlocks;
CurLoop->getUniqueExitBlocks(ExitBlocks);
- SmallPtrSet<BasicBlock *, 32> ExitBlockSet(ExitBlocks.begin(),
- ExitBlocks.end());
+ SmallPtrSet<BasicBlock *, 32> ExitBlockSet(llvm::from_range, ExitBlocks);
#endif
BasicBlock *ExitBB = PN->getParent();
assert(ExitBlockSet.count(ExitBB) && "Expect the PHI is in an exit block.");
@@ -1699,8 +1698,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
#ifndef NDEBUG
SmallVector<BasicBlock *, 32> ExitBlocks;
CurLoop->getUniqueExitBlocks(ExitBlocks);
- SmallPtrSet<BasicBlock *, 32> ExitBlockSet(ExitBlocks.begin(),
- ExitBlocks.end());
+ SmallPtrSet<BasicBlock *, 32> ExitBlockSet(llvm::from_range, ExitBlocks);
#endif
// Clones of this instruction. Don't create more than one per exit block!
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index ce5bf0c7207c7..6f36e24000aa5 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -102,7 +102,7 @@ void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, DomTreeUpdater *DTU,
bool KeepOneInputPHIs) {
#ifndef NDEBUG
// Make sure that all predecessors of each dead block is also dead.
- SmallPtrSet<BasicBlock *, 4> Dead(BBs.begin(), BBs.end());
+ SmallPtrSet<BasicBlock *, 4> Dead(llvm::from_range, BBs);
assert(Dead.size() == BBs.size() && "Duplicating blocks?");
for (auto *BB : Dead)
for (BasicBlock *Pred : predecessors(BB))
@@ -1261,7 +1261,7 @@ static void UpdatePHINodes(BasicBlock *OrigBB, BasicBlock *NewBB,
ArrayRef<BasicBlock *> Preds, BranchInst *BI,
bool HasLoopExit) {
// Otherwise, create a new PHI node in NewBB for each PHI node in OrigBB.
- SmallPtrSet<BasicBlock *, 16> PredSet(Preds.begin(), Preds.end());
+ SmallPtrSet<BasicBlock *, 16> PredSet(llvm::from_range, Preds);
for (BasicBlock::iterator I = OrigBB->begin(); isa<PHINode>(I); ) {
PHINode *PN = cast<PHINode>(I++);
diff --git a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
index 92b5d444aac34..afe834ee201bb 100644
--- a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
+++ b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
@@ -87,8 +87,7 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
SmallVector<std::string, 8> Mappings;
VFABI::getVectorVariantNames(CI, Mappings);
Module *M = CI.getModule();
- const SetVector<StringRef> OriginalSetOfMappings(Mappings.begin(),
- Mappings.end());
+ const SetVector<StringRef> OriginalSetOfMappings(llvm::from_range, Mappings);
auto AddVariantDecl = [&](const ElementCount &VF, bool Predicate) {
const VecDesc *VD = TLI.getVectorMappingInfo(ScalarName, VF, Predicate);
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index 05fd989271c32..c0c58237ddfca 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -815,8 +815,8 @@ void PromoteMem2Reg::run() {
AllocaLookup[Allocas[AllocaNum]] = AllocaNum;
// Unique the set of defining blocks for efficient lookup.
- SmallPtrSet<BasicBlock *, 32> DefBlocks(Info.DefiningBlocks.begin(),
- Info.DefiningBlocks.end());
+ SmallPtrSet<BasicBlock *, 32> DefBlocks(llvm::from_range,
+ Info.DefiningBlocks);
// Determine which blocks the value is live in. These are blocks which lead
// to uses.
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index d429fe96f9bec..41bf202230e22 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2389,8 +2389,8 @@ void SCEVExpanderCleaner::cleanup() {
auto InsertedInstructions = Expander.getAllInsertedInstructions();
#ifndef NDEBUG
- SmallPtrSet<Instruction *, 8> InsertedSet(InsertedInstructions.begin(),
- InsertedInstructions.end());
+ SmallPtrSet<Instruction *, 8> InsertedSet(llvm::from_range,
+ InsertedInstructions);
(void)InsertedSet;
#endif
// Remove sets with value handles.
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 02f1d08759129..fd83ec1a7f4fe 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2721,7 +2721,7 @@ bool CompatibleSets::shouldBelongToSameSet(ArrayRef<InvokeInst *> Invokes) {
// In the normal destination, the incoming values for these two `invoke`s
// must be compatible.
- SmallPtrSet<Value *, 16> EquivalenceSet(Invokes.begin(), Invokes.end());
+ SmallPtrSet<Value *, 16> EquivalenceSet(llvm::from_range, Invokes);
if (!incomingValuesAreCompatible(
NormalBB, {Invokes[0]->getParent(), Invokes[1]->getParent()},
&EquivalenceSet))
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index e121782811851..276e9000ec6ad 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7325,8 +7325,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
continue;
const auto &ChainOps = RdxDesc.getReductionOpChain(RedPhi, OrigLoop);
- SetVector<Instruction *> ChainOpsAndOperands(ChainOps.begin(),
- ChainOps.end());
+ SetVector<Instruction *> ChainOpsAndOperands(llvm::from_range, ChainOps);
auto IsZExtOrSExt = [](const unsigned Opcode) -> bool {
return Opcode == Instruction::ZExt || Opcode == Instruction::SExt;
};
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 7741f96ee897b..40d11444ea39f 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1821,7 +1821,7 @@ class BoUpSLP {
auto CheckSameEntryOrFail = [&]() {
if (ArrayRef<TreeEntry *> TEs1 = R.getTreeEntries(V1); !TEs1.empty()) {
- SmallPtrSet<TreeEntry *, 4> Set(TEs1.begin(), TEs1.end());
+ SmallPtrSet<TreeEntry *, 4> Set(llvm::from_range, TEs1);
if (ArrayRef<TreeEntry *> TEs2 = R.getTreeEntries(V2);
!TEs2.empty() &&
any_of(TEs2, [&](TreeEntry *E) { return Set.contains(E); }))
@@ -8938,7 +8938,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
}
return;
}
- SmallPtrSet<Value *, 8> Values(E->Scalars.begin(), E->Scalars.end());
+ SmallPtrSet<Value *, 8> Values(llvm::from_range, E->Scalars);
if (all_of(VL, [&](Value *V) {
return isa<PoisonValue>(V) || Values.contains(V);
})) {
@@ -9038,8 +9038,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
SmallBitVector OpcodeMask(getAltInstrMask(VL, Opcode0, Opcode1));
// Enable split node, only if all nodes do not form legal alternate
// instruction (like X86 addsub).
- SmallPtrSet<Value *, 4> UOp1(Op1.begin(), Op1.end());
- SmallPtrSet<Value *, 4> UOp2(Op2.begin(), Op2.end());
+ SmallPtrSet<Value *, 4> UOp1(llvm::from_range, Op1);
+ SmallPtrSet<Value *, 4> UOp2(llvm::from_range, Op2);
if (UOp1.size() <= 1 || UOp2.size() <= 1 ||
TTI.isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask) ||
!hasFullVectorsOrPowerOf2(TTI, Op1.front()->getType(), Op1.size()) ||
@@ -14265,7 +14265,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
return std::nullopt;
auto *NodeUI = DT->getNode(TEInsertBlock);
assert(NodeUI && "Should only process reachable instructions");
- SmallPtrSet<Value *, 4> GatheredScalars(VL.begin(), VL.end());
+ SmallPtrSet<Value *, 4> GatheredScalars(llvm::from_range, VL);
auto CheckOrdering = [&](const Instruction *InsertPt) {
// Argument InsertPt is an instruction where vector code for some other
// tree entry (one that shares one or more scalars with TE) is going to be
@@ -21455,7 +21455,7 @@ class HorizontalReduction {
}
}
V.transformNodes();
- SmallPtrSet<Value *, 4> VLScalars(VL.begin(), VL.end());
+ SmallPtrSet<Value *, 4> VLScalars(llvm::from_range, VL);
// Gather externally used values.
SmallPtrSet<Value *, 4> Visited;
for (unsigned Cnt = 0; Cnt < NumReducedVals; ++Cnt) {
@@ -23343,7 +23343,7 @@ bool SLPVectorizerPass::vectorizeGEPIndices(BasicBlock *BB, BoUpSLP &R) {
// SetVector here to preserve program order. If the index computations
// are vectorizable and begin with loads, we want to minimize the chance
// of having to reorder them later.
- SetVector<Value *> Candidates(GEPList.begin(), GEPList.end());
+ SetVector<Value *> Candidates(llvm::from_range, GEPList);
// Some of the candidates may have already been vectorized after we
// initially collected them or their index is optimized to constant value.
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
index a80ae2aefff0a..f32d57fa67daa 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
@@ -219,7 +219,7 @@ const LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl,
[BB](auto *V) { return cast<Instruction>(V)->getParent() != BB; }))
return createLegalityResult<Pack>(ResultReason::DiffBBs);
// Pack if instructions repeat, i.e., require some sort of broadcast.
- SmallPtrSet<Value *, 8> Unique(Bndl.begin(), Bndl.end());
+ SmallPtrSet<Value *, 8> Unique(llvm::from_range, Bndl);
if (Unique.size() != Bndl.size())
return createLegalityResult<Pack>(ResultReason::RepeatedInstrs);
|
@llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/133203.diff 15 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/ExtractGV.cpp b/llvm/lib/Transforms/IPO/ExtractGV.cpp
index 7b37453611032..16fdb93e2b21b 100644
--- a/llvm/lib/Transforms/IPO/ExtractGV.cpp
+++ b/llvm/lib/Transforms/IPO/ExtractGV.cpp
@@ -52,7 +52,7 @@ static void makeVisible(GlobalValue &GV, bool Delete) {
/// global values specified.
ExtractGVPass::ExtractGVPass(std::vector<GlobalValue *> &GVs, bool deleteS,
bool keepConstInit)
- : Named(GVs.begin(), GVs.end()), deleteStuff(deleteS),
+ : Named(llvm::from_range, GVs), deleteStuff(deleteS),
keepConstInit(keepConstInit) {}
PreservedAnalyses ExtractGVPass::run(Module &M, ModuleAnalysisManager &) {
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 2d046f09f1b2b..83cc1e5f04f3d 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2319,10 +2319,10 @@ class LLVMUsed {
LLVMUsed(Module &M) {
SmallVector<GlobalValue *, 4> Vec;
UsedV = collectUsedGlobalVariables(M, Vec, false);
- Used = {Vec.begin(), Vec.end()};
+ Used = {llvm::from_range, Vec};
Vec.clear();
CompilerUsedV = collectUsedGlobalVariables(M, Vec, true);
- CompilerUsed = {Vec.begin(), Vec.end()};
+ CompilerUsed = {llvm::from_range, Vec};
}
using iterator = SmallPtrSet<GlobalValue *, 4>::iterator;
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 29bf214a5c9e7..82c3d9dbb3fc3 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -5874,7 +5874,7 @@ PreservedAnalyses OpenMPOptCGSCCPass::run(LazyCallGraph::SCC &C,
bool PostLink = LTOPhase == ThinOrFullLTOPhase::FullLTOPostLink ||
LTOPhase == ThinOrFullLTOPhase::ThinLTOPostLink ||
LTOPhase == ThinOrFullLTOPhase::ThinLTOPreLink;
- SetVector<Function *> Functions(SCC.begin(), SCC.end());
+ SetVector<Function *> Functions(llvm::from_range, SCC);
OMPInformationCache InfoCache(*(Functions.back()->getParent()), AG, Allocator,
/*CGSCC*/ &Functions, PostLink);
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index b41899a2dff66..93b629d531ad8 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1591,8 +1591,7 @@ bool GVNPass::PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
// that we only have to insert *one* load (which means we're basically moving
// the load, not inserting a new one).
- SmallPtrSet<BasicBlock *, 4> Blockers(UnavailableBlocks.begin(),
- UnavailableBlocks.end());
+ SmallPtrSet<BasicBlock *, 4> Blockers(llvm::from_range, UnavailableBlocks);
// Let's find the first basic block with more than one predecessor. Walk
// backwards through predecessors if needed.
diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index 24d7f9381c045..d0f844d7cd36a 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -522,7 +522,7 @@ class GVNSink {
unsigned NumSunk = 0;
ReversePostOrderTraversal<Function*> RPOT(&F);
- VN.setReachableBBs(BasicBlocksSet(RPOT.begin(), RPOT.end()));
+ VN.setReachableBBs(BasicBlocksSet(llvm::from_range, RPOT));
// Populate reverse post-order to order basic blocks in deterministic
// order. Any arbitrary ordering will work in this case as long as they are
// deterministic. The node ordering of newly created basic blocks
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index 798498292f381..73a3f5e4d3694 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -895,7 +895,7 @@ void InferAddressSpacesImpl::inferAddressSpaces(
ArrayRef<WeakTrackingVH> Postorder,
ValueToAddrSpaceMapTy &InferredAddrSpace,
PredicatedAddrSpaceMapTy &PredicatedAS) const {
- SetVector<Value *> Worklist(Postorder.begin(), Postorder.end());
+ SetVector<Value *> Worklist(llvm::from_range, Postorder);
// Initially, all expressions are in the uninitialized address space.
for (Value *V : Postorder)
InferredAddrSpace[V] = UninitializedAddressSpace;
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 39f72703bd46e..d872a381050ca 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1564,8 +1564,7 @@ static void splitPredecessorsOfLoopExit(PHINode *PN, DominatorTree *DT,
#ifndef NDEBUG
SmallVector<BasicBlock *, 32> ExitBlocks;
CurLoop->getUniqueExitBlocks(ExitBlocks);
- SmallPtrSet<BasicBlock *, 32> ExitBlockSet(ExitBlocks.begin(),
- ExitBlocks.end());
+ SmallPtrSet<BasicBlock *, 32> ExitBlockSet(llvm::from_range, ExitBlocks);
#endif
BasicBlock *ExitBB = PN->getParent();
assert(ExitBlockSet.count(ExitBB) && "Expect the PHI is in an exit block.");
@@ -1699,8 +1698,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
#ifndef NDEBUG
SmallVector<BasicBlock *, 32> ExitBlocks;
CurLoop->getUniqueExitBlocks(ExitBlocks);
- SmallPtrSet<BasicBlock *, 32> ExitBlockSet(ExitBlocks.begin(),
- ExitBlocks.end());
+ SmallPtrSet<BasicBlock *, 32> ExitBlockSet(llvm::from_range, ExitBlocks);
#endif
// Clones of this instruction. Don't create more than one per exit block!
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index ce5bf0c7207c7..6f36e24000aa5 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -102,7 +102,7 @@ void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, DomTreeUpdater *DTU,
bool KeepOneInputPHIs) {
#ifndef NDEBUG
// Make sure that all predecessors of each dead block is also dead.
- SmallPtrSet<BasicBlock *, 4> Dead(BBs.begin(), BBs.end());
+ SmallPtrSet<BasicBlock *, 4> Dead(llvm::from_range, BBs);
assert(Dead.size() == BBs.size() && "Duplicating blocks?");
for (auto *BB : Dead)
for (BasicBlock *Pred : predecessors(BB))
@@ -1261,7 +1261,7 @@ static void UpdatePHINodes(BasicBlock *OrigBB, BasicBlock *NewBB,
ArrayRef<BasicBlock *> Preds, BranchInst *BI,
bool HasLoopExit) {
// Otherwise, create a new PHI node in NewBB for each PHI node in OrigBB.
- SmallPtrSet<BasicBlock *, 16> PredSet(Preds.begin(), Preds.end());
+ SmallPtrSet<BasicBlock *, 16> PredSet(llvm::from_range, Preds);
for (BasicBlock::iterator I = OrigBB->begin(); isa<PHINode>(I); ) {
PHINode *PN = cast<PHINode>(I++);
diff --git a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
index 92b5d444aac34..afe834ee201bb 100644
--- a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
+++ b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
@@ -87,8 +87,7 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
SmallVector<std::string, 8> Mappings;
VFABI::getVectorVariantNames(CI, Mappings);
Module *M = CI.getModule();
- const SetVector<StringRef> OriginalSetOfMappings(Mappings.begin(),
- Mappings.end());
+ const SetVector<StringRef> OriginalSetOfMappings(llvm::from_range, Mappings);
auto AddVariantDecl = [&](const ElementCount &VF, bool Predicate) {
const VecDesc *VD = TLI.getVectorMappingInfo(ScalarName, VF, Predicate);
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index 05fd989271c32..c0c58237ddfca 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -815,8 +815,8 @@ void PromoteMem2Reg::run() {
AllocaLookup[Allocas[AllocaNum]] = AllocaNum;
// Unique the set of defining blocks for efficient lookup.
- SmallPtrSet<BasicBlock *, 32> DefBlocks(Info.DefiningBlocks.begin(),
- Info.DefiningBlocks.end());
+ SmallPtrSet<BasicBlock *, 32> DefBlocks(llvm::from_range,
+ Info.DefiningBlocks);
// Determine which blocks the value is live in. These are blocks which lead
// to uses.
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index d429fe96f9bec..41bf202230e22 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2389,8 +2389,8 @@ void SCEVExpanderCleaner::cleanup() {
auto InsertedInstructions = Expander.getAllInsertedInstructions();
#ifndef NDEBUG
- SmallPtrSet<Instruction *, 8> InsertedSet(InsertedInstructions.begin(),
- InsertedInstructions.end());
+ SmallPtrSet<Instruction *, 8> InsertedSet(llvm::from_range,
+ InsertedInstructions);
(void)InsertedSet;
#endif
// Remove sets with value handles.
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 02f1d08759129..fd83ec1a7f4fe 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2721,7 +2721,7 @@ bool CompatibleSets::shouldBelongToSameSet(ArrayRef<InvokeInst *> Invokes) {
// In the normal destination, the incoming values for these two `invoke`s
// must be compatible.
- SmallPtrSet<Value *, 16> EquivalenceSet(Invokes.begin(), Invokes.end());
+ SmallPtrSet<Value *, 16> EquivalenceSet(llvm::from_range, Invokes);
if (!incomingValuesAreCompatible(
NormalBB, {Invokes[0]->getParent(), Invokes[1]->getParent()},
&EquivalenceSet))
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index e121782811851..276e9000ec6ad 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7325,8 +7325,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
continue;
const auto &ChainOps = RdxDesc.getReductionOpChain(RedPhi, OrigLoop);
- SetVector<Instruction *> ChainOpsAndOperands(ChainOps.begin(),
- ChainOps.end());
+ SetVector<Instruction *> ChainOpsAndOperands(llvm::from_range, ChainOps);
auto IsZExtOrSExt = [](const unsigned Opcode) -> bool {
return Opcode == Instruction::ZExt || Opcode == Instruction::SExt;
};
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 7741f96ee897b..40d11444ea39f 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1821,7 +1821,7 @@ class BoUpSLP {
auto CheckSameEntryOrFail = [&]() {
if (ArrayRef<TreeEntry *> TEs1 = R.getTreeEntries(V1); !TEs1.empty()) {
- SmallPtrSet<TreeEntry *, 4> Set(TEs1.begin(), TEs1.end());
+ SmallPtrSet<TreeEntry *, 4> Set(llvm::from_range, TEs1);
if (ArrayRef<TreeEntry *> TEs2 = R.getTreeEntries(V2);
!TEs2.empty() &&
any_of(TEs2, [&](TreeEntry *E) { return Set.contains(E); }))
@@ -8938,7 +8938,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
}
return;
}
- SmallPtrSet<Value *, 8> Values(E->Scalars.begin(), E->Scalars.end());
+ SmallPtrSet<Value *, 8> Values(llvm::from_range, E->Scalars);
if (all_of(VL, [&](Value *V) {
return isa<PoisonValue>(V) || Values.contains(V);
})) {
@@ -9038,8 +9038,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
SmallBitVector OpcodeMask(getAltInstrMask(VL, Opcode0, Opcode1));
// Enable split node, only if all nodes do not form legal alternate
// instruction (like X86 addsub).
- SmallPtrSet<Value *, 4> UOp1(Op1.begin(), Op1.end());
- SmallPtrSet<Value *, 4> UOp2(Op2.begin(), Op2.end());
+ SmallPtrSet<Value *, 4> UOp1(llvm::from_range, Op1);
+ SmallPtrSet<Value *, 4> UOp2(llvm::from_range, Op2);
if (UOp1.size() <= 1 || UOp2.size() <= 1 ||
TTI.isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask) ||
!hasFullVectorsOrPowerOf2(TTI, Op1.front()->getType(), Op1.size()) ||
@@ -14265,7 +14265,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
return std::nullopt;
auto *NodeUI = DT->getNode(TEInsertBlock);
assert(NodeUI && "Should only process reachable instructions");
- SmallPtrSet<Value *, 4> GatheredScalars(VL.begin(), VL.end());
+ SmallPtrSet<Value *, 4> GatheredScalars(llvm::from_range, VL);
auto CheckOrdering = [&](const Instruction *InsertPt) {
// Argument InsertPt is an instruction where vector code for some other
// tree entry (one that shares one or more scalars with TE) is going to be
@@ -21455,7 +21455,7 @@ class HorizontalReduction {
}
}
V.transformNodes();
- SmallPtrSet<Value *, 4> VLScalars(VL.begin(), VL.end());
+ SmallPtrSet<Value *, 4> VLScalars(llvm::from_range, VL);
// Gather externally used values.
SmallPtrSet<Value *, 4> Visited;
for (unsigned Cnt = 0; Cnt < NumReducedVals; ++Cnt) {
@@ -23343,7 +23343,7 @@ bool SLPVectorizerPass::vectorizeGEPIndices(BasicBlock *BB, BoUpSLP &R) {
// SetVector here to preserve program order. If the index computations
// are vectorizable and begin with loads, we want to minimize the chance
// of having to reorder them later.
- SetVector<Value *> Candidates(GEPList.begin(), GEPList.end());
+ SetVector<Value *> Candidates(llvm::from_range, GEPList);
// Some of the candidates may have already been vectorized after we
// initially collected them or their index is optimized to constant value.
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
index a80ae2aefff0a..f32d57fa67daa 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
@@ -219,7 +219,7 @@ const LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl,
[BB](auto *V) { return cast<Instruction>(V)->getParent() != BB; }))
return createLegalityResult<Pack>(ResultReason::DiffBBs);
// Pack if instructions repeat, i.e., require some sort of broadcast.
- SmallPtrSet<Value *, 8> Unique(Bndl.begin(), Bndl.end());
+ SmallPtrSet<Value *, 8> Unique(llvm::from_range, Bndl);
if (Unique.size() != Bndl.size())
return createLegalityResult<Pack>(ResultReason::RepeatedInstrs);
|
kuhar
approved these changes
Mar 27, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.