From 511811ef346df0f76b11580cd16c24a3d6357c93 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 29 Mar 2025 15:08:15 -0700 Subject: [PATCH] [Analysis] Use llvm::append_range (NFC) --- llvm/lib/Analysis/IRSimilarityIdentifier.cpp | 3 +-- llvm/lib/Analysis/IVDescriptors.cpp | 7 ++----- llvm/lib/Analysis/LoopAccessAnalysis.cpp | 3 +-- llvm/lib/Analysis/ScalarEvolution.cpp | 9 +++------ 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp index ca011362702ac..a6af7304b1c7e 100644 --- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp +++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp @@ -78,8 +78,7 @@ void IRInstructionData::initializeInstruction() { // We capture the incoming BasicBlocks as values as well as the incoming // Values in order to check for structural similarity. if (PHINode *PN = dyn_cast(Inst)) - for (BasicBlock *BB : PN->blocks()) - OperVals.push_back(BB); + llvm::append_range(OperVals, PN->blocks()); } IRInstructionData::IRInstructionData(IRInstructionDataList &IDList) diff --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp index 45b5b2979a562..94c347b01bbfb 100644 --- a/llvm/lib/Analysis/IVDescriptors.cpp +++ b/llvm/lib/Analysis/IVDescriptors.cpp @@ -1296,11 +1296,8 @@ InductionDescriptor::InductionDescriptor(Value *Start, InductionKind K, InductionBinOp->getOpcode() == Instruction::FSub))) && "Binary opcode should be specified for FP induction"); - if (Casts) { - for (auto &Inst : *Casts) { - RedundantCasts.push_back(Inst); - } - } + if (Casts) + llvm::append_range(RedundantCasts, *Casts); } ConstantInt *InductionDescriptor::getConstIntStepValue() const { diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 57a76bc7a81e5..7f1b5dc3890a9 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -913,8 +913,7 @@ static void visitPointers(Value *StartPtr, const Loop &InnermostLoop, // value. if (PN && InnermostLoop.contains(PN->getParent()) && PN->getParent() != InnermostLoop.getHeader()) { - for (const Use &Inc : PN->incoming_values()) - WorkList.push_back(Inc); + llvm::append_range(WorkList, PN->incoming_values()); } else AddPointer(Ptr); } diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 600a061d4435e..361206719287a 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -4221,8 +4221,7 @@ bool ScalarEvolution::canReuseInstruction( if (I->hasPoisonGeneratingAnnotations()) DropPoisonGeneratingInsts.push_back(I); - for (Value *Op : I->operands()) - Worklist.push_back(Op); + llvm::append_range(Worklist, I->operands()); } return true; } @@ -7622,8 +7621,7 @@ ScalarEvolution::getOperandsToCreate(Value *V, SmallVectorImpl &Ops) { case Instruction::GetElementPtr: assert(cast(U)->getSourceElementType()->isSized() && "GEP source element type must be sized"); - for (Value *Index : U->operands()) - Ops.push_back(Index); + llvm::append_range(Ops, U->operands()); return nullptr; case Instruction::IntToPtr: @@ -7656,8 +7654,7 @@ ScalarEvolution::getOperandsToCreate(Value *V, SmallVectorImpl &Ops) { if (CanSimplifyToUnknown()) return getUnknown(U); - for (Value *Inc : U->operands()) - Ops.push_back(Inc); + llvm::append_range(Ops, U->operands()); return nullptr; break; }