[llvm] Use range constructors of *Set (NFC) (#137552)
This commit is contained in:
parent
25b05e0b23
commit
5cfd81b0cc
@ -679,8 +679,8 @@ void MemorySSAUpdater::updateForClonedLoop(const LoopBlocksRPO &LoopBlocks,
|
||||
auto FixPhiIncomingValues = [&](MemoryPhi *Phi, MemoryPhi *NewPhi) {
|
||||
assert(Phi && NewPhi && "Invalid Phi nodes.");
|
||||
BasicBlock *NewPhiBB = NewPhi->getBlock();
|
||||
SmallPtrSet<BasicBlock *, 4> NewPhiBBPreds(pred_begin(NewPhiBB),
|
||||
pred_end(NewPhiBB));
|
||||
SmallPtrSet<BasicBlock *, 4> NewPhiBBPreds(llvm::from_range,
|
||||
predecessors(NewPhiBB));
|
||||
for (unsigned It = 0, E = Phi->getNumIncomingValues(); It < E; ++It) {
|
||||
MemoryAccess *IncomingAccess = Phi->getIncomingValue(It);
|
||||
BasicBlock *IncBB = Phi->getIncomingBlock(It);
|
||||
|
@ -1024,8 +1024,8 @@ bool MachineBlockPlacement::isTrellis(
|
||||
if (BB->succ_size() != 2 || ViableSuccs.size() != 2)
|
||||
return false;
|
||||
|
||||
SmallPtrSet<const MachineBasicBlock *, 2> Successors(BB->succ_begin(),
|
||||
BB->succ_end());
|
||||
SmallPtrSet<const MachineBasicBlock *, 2> Successors(llvm::from_range,
|
||||
BB->successors());
|
||||
// To avoid reviewing the same predecessors twice.
|
||||
SmallPtrSet<const MachineBasicBlock *, 8> SeenPreds;
|
||||
|
||||
@ -1117,8 +1117,8 @@ MachineBlockPlacement::getBestTrellisSuccessor(
|
||||
const BlockFilterSet *BlockFilter) {
|
||||
|
||||
BlockAndTailDupResult Result = {nullptr, false};
|
||||
SmallPtrSet<const MachineBasicBlock *, 4> Successors(BB->succ_begin(),
|
||||
BB->succ_end());
|
||||
SmallPtrSet<const MachineBasicBlock *, 4> Successors(llvm::from_range,
|
||||
BB->successors());
|
||||
|
||||
// We assume size 2 because it's common. For general n, we would have to do
|
||||
// the Hungarian algorithm, but it's not worth the complexity because more
|
||||
@ -1209,8 +1209,8 @@ bool MachineBlockPlacement::canTailDuplicateUnplacedPreds(
|
||||
unsigned int NumDup = 0;
|
||||
|
||||
// For CFG checking.
|
||||
SmallPtrSet<const MachineBasicBlock *, 4> Successors(BB->succ_begin(),
|
||||
BB->succ_end());
|
||||
SmallPtrSet<const MachineBasicBlock *, 4> Successors(llvm::from_range,
|
||||
BB->successors());
|
||||
for (MachineBasicBlock *Pred : Succ->predecessors()) {
|
||||
// Make sure all unplaced and unfiltered predecessors can be
|
||||
// tail-duplicated into.
|
||||
|
@ -751,8 +751,8 @@ bool TailDuplicator::canCompletelyDuplicateBB(MachineBasicBlock &BB) {
|
||||
bool TailDuplicator::duplicateSimpleBB(
|
||||
MachineBasicBlock *TailBB, SmallVectorImpl<MachineBasicBlock *> &TDBBs,
|
||||
const DenseSet<Register> &UsedByPhi) {
|
||||
SmallPtrSet<MachineBasicBlock *, 8> Succs(TailBB->succ_begin(),
|
||||
TailBB->succ_end());
|
||||
SmallPtrSet<MachineBasicBlock *, 8> Succs(llvm::from_range,
|
||||
TailBB->successors());
|
||||
SmallVector<MachineBasicBlock *, 8> Preds(TailBB->predecessors());
|
||||
bool Changed = false;
|
||||
for (MachineBasicBlock *PredBB : Preds) {
|
||||
|
@ -1043,7 +1043,7 @@ bool TargetInstrInfo::getAccumulatorReassociationPatterns(
|
||||
|
||||
// Check if the MBB this instruction is a part of contains any other chains.
|
||||
// If so, don't apply it.
|
||||
SmallSet<Register, 32> ReductionChain(Chain.begin(), Chain.end());
|
||||
SmallSet<Register, 32> ReductionChain(llvm::from_range, Chain);
|
||||
for (const auto &I : MBB) {
|
||||
if (I.getOpcode() == Opc &&
|
||||
!ReductionChain.contains(I.getOperand(0).getReg()))
|
||||
|
@ -185,8 +185,8 @@ bool UnreachableMachineBlockElim::run(MachineFunction &F) {
|
||||
// Cleanup PHI nodes.
|
||||
for (MachineBasicBlock &BB : F) {
|
||||
// Prune unneeded PHI entries.
|
||||
SmallPtrSet<MachineBasicBlock*, 8> preds(BB.pred_begin(),
|
||||
BB.pred_end());
|
||||
SmallPtrSet<MachineBasicBlock *, 8> preds(llvm::from_range,
|
||||
BB.predecessors());
|
||||
for (MachineInstr &Phi : make_early_inc_range(BB.phis())) {
|
||||
for (unsigned i = Phi.getNumOperands() - 1; i >= 2; i -= 2) {
|
||||
if (!preds.count(Phi.getOperand(i).getMBB())) {
|
||||
|
@ -382,7 +382,7 @@ void HexagonExpandCondsets::updateDeadsInRange(Register Reg, LaneBitmask LM,
|
||||
return true;
|
||||
}
|
||||
MachineBasicBlock *Entry = &Dest->getParent()->front();
|
||||
SetVector<MachineBasicBlock*> Work(Dest->pred_begin(), Dest->pred_end());
|
||||
SetVector<MachineBasicBlock *> Work(llvm::from_range, Dest->predecessors());
|
||||
for (unsigned i = 0; i < Work.size(); ++i) {
|
||||
MachineBasicBlock *B = Work[i];
|
||||
if (Defs.count(B))
|
||||
|
@ -485,10 +485,8 @@ void AggressiveDeadCodeElimination::markLiveBranchesFromControlDependences() {
|
||||
// which currently have dead terminators that are control
|
||||
// dependence sources of a block which is in NewLiveBlocks.
|
||||
|
||||
const SmallPtrSet<BasicBlock *, 16> BWDT{
|
||||
BlocksWithDeadTerminators.begin(),
|
||||
BlocksWithDeadTerminators.end()
|
||||
};
|
||||
const SmallPtrSet<BasicBlock *, 16> BWDT(llvm::from_range,
|
||||
BlocksWithDeadTerminators);
|
||||
SmallVector<BasicBlock *, 32> IDFBlocks;
|
||||
ReverseIDFCalculator IDFs(PDT);
|
||||
IDFs.setDefiningBlocks(NewLiveBlocks);
|
||||
|
@ -249,8 +249,8 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
|
||||
assert(!DT && "cannot use both DT and DTU for updates");
|
||||
// To avoid processing the same predecessor more than once.
|
||||
SmallPtrSet<BasicBlock *, 8> SeenSuccs;
|
||||
SmallPtrSet<BasicBlock *, 2> SuccsOfPredBB(succ_begin(PredBB),
|
||||
succ_end(PredBB));
|
||||
SmallPtrSet<BasicBlock *, 2> SuccsOfPredBB(llvm::from_range,
|
||||
successors(PredBB));
|
||||
Updates.reserve(Updates.size() + 2 * succ_size(BB) + 1);
|
||||
// Add insert edges first. Experimentally, for the particular case of two
|
||||
// blocks that can be merged, with a single successor and single predecessor
|
||||
|
@ -144,7 +144,7 @@ bool FlattenCFGOpt::FlattenParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder) {
|
||||
int Idx = -1;
|
||||
|
||||
// Check predecessors of \param BB.
|
||||
SmallPtrSet<BasicBlock *, 16> Preds(pred_begin(BB), pred_end(BB));
|
||||
SmallPtrSet<BasicBlock *, 16> Preds(llvm::from_range, predecessors(BB));
|
||||
for (BasicBlock *Pred : Preds) {
|
||||
BranchInst *PBI = dyn_cast<BranchInst>(Pred->getTerminator());
|
||||
|
||||
|
@ -1158,7 +1158,7 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
|
||||
if (BB == Succ)
|
||||
return false;
|
||||
|
||||
SmallPtrSet<BasicBlock *, 16> BBPreds(pred_begin(BB), pred_end(BB));
|
||||
SmallPtrSet<BasicBlock *, 16> BBPreds(llvm::from_range, predecessors(BB));
|
||||
|
||||
// The single common predecessor of BB and Succ when BB cannot be killed
|
||||
BasicBlock *CommonPred = nullptr;
|
||||
@ -1293,7 +1293,8 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
|
||||
// All predecessors of BB (except the common predecessor) will be moved to
|
||||
// Succ.
|
||||
Updates.reserve(Updates.size() + 2 * pred_size(BB) + 1);
|
||||
SmallPtrSet<BasicBlock *, 16> SuccPreds(pred_begin(Succ), pred_end(Succ));
|
||||
SmallPtrSet<BasicBlock *, 16> SuccPreds(llvm::from_range,
|
||||
predecessors(Succ));
|
||||
for (auto *PredOfBB : predecessors(BB)) {
|
||||
// Do not modify those common predecessors of BB and Succ
|
||||
if (!SuccPreds.contains(PredOfBB))
|
||||
|
@ -367,7 +367,7 @@ safeToMergeTerminators(Instruction *SI1, Instruction *SI2,
|
||||
BasicBlock *SI1BB = SI1->getParent();
|
||||
BasicBlock *SI2BB = SI2->getParent();
|
||||
|
||||
SmallPtrSet<BasicBlock *, 16> SI1Succs(succ_begin(SI1BB), succ_end(SI1BB));
|
||||
SmallPtrSet<BasicBlock *, 16> SI1Succs(llvm::from_range, successors(SI1BB));
|
||||
bool Fail = false;
|
||||
for (BasicBlock *Succ : successors(SI2BB)) {
|
||||
if (!SI1Succs.count(Succ))
|
||||
@ -1332,7 +1332,7 @@ bool SimplifyCFGOpt::performValueComparisonIntoPredecessorFolding(
|
||||
// successors.
|
||||
SmallPtrSet<BasicBlock *, 2> SuccsOfPred;
|
||||
if (DTU) {
|
||||
SuccsOfPred = {succ_begin(Pred), succ_end(Pred)};
|
||||
SuccsOfPred = {llvm::from_range, successors(Pred)};
|
||||
Updates.reserve(Updates.size() + NewSuccessors.size());
|
||||
}
|
||||
for (const std::pair<BasicBlock *, int /*Num*/> &NewSuccessor :
|
||||
|
@ -8425,7 +8425,7 @@ void VPRecipeBuilder::createBlockInMask(BasicBlock *BB) {
|
||||
VPValue *BlockMask = nullptr;
|
||||
// This is the block mask. We OR all unique incoming edges.
|
||||
for (auto *Predecessor :
|
||||
SetVector<BasicBlock *>(pred_begin(BB), pred_end(BB))) {
|
||||
SetVector<BasicBlock *>(llvm::from_range, predecessors(BB))) {
|
||||
VPValue *EdgeMask = createEdgeMask(Predecessor, BB);
|
||||
if (!EdgeMask) { // Mask of predecessor is all-one so mask of block is too.
|
||||
BlockMaskCache[BB] = EdgeMask;
|
||||
|
@ -10107,7 +10107,7 @@ void BoUpSLP::buildTreeRec(ArrayRef<Value *> VL, unsigned Depth,
|
||||
|
||||
BlockScheduling &BS = *BSRef;
|
||||
|
||||
SetVector<Value *> UniqueValues(VL.begin(), VL.end());
|
||||
SetVector<Value *> UniqueValues(llvm::from_range, VL);
|
||||
std::optional<ScheduleBundle *> BundlePtr =
|
||||
BS.tryScheduleBundle(UniqueValues.getArrayRef(), this, S);
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
|
@ -597,7 +597,7 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
|
||||
}
|
||||
|
||||
static SmallVector<VPUser *> collectUsersRecursively(VPValue *V) {
|
||||
SetVector<VPUser *> Users(V->user_begin(), V->user_end());
|
||||
SetVector<VPUser *> Users(llvm::from_range, V->users());
|
||||
for (unsigned I = 0; I != Users.size(); ++I) {
|
||||
VPRecipeBase *Cur = cast<VPRecipeBase>(Users[I]);
|
||||
if (isa<VPHeaderPHIRecipe>(Cur))
|
||||
|
Loading…
x
Reference in New Issue
Block a user