[Transforms] Use range-based for loops (NFC) (#145252)
Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
This commit is contained in:
@@ -250,10 +250,10 @@ CleanupPointerRootUsers(GlobalVariable *GV,
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0, e = Dead.size(); i != e; ++i) {
|
||||
if (IsSafeComputationToRemove(Dead[i].first, GetTLI)) {
|
||||
Dead[i].second->eraseFromParent();
|
||||
Instruction *I = Dead[i].first;
|
||||
for (const auto &[Inst, Store] : Dead) {
|
||||
if (IsSafeComputationToRemove(Inst, GetTLI)) {
|
||||
Store->eraseFromParent();
|
||||
Instruction *I = Inst;
|
||||
do {
|
||||
if (isAllocationFn(I, GetTLI))
|
||||
break;
|
||||
|
||||
@@ -3494,13 +3494,13 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
|
||||
auto Removable =
|
||||
isAllocSiteRemovable(&MI, Users, TLI, KnowInitZero | KnowInitUndef);
|
||||
if (Removable) {
|
||||
for (unsigned i = 0, e = Users.size(); i != e; ++i) {
|
||||
for (WeakTrackingVH &User : Users) {
|
||||
// Lowering all @llvm.objectsize and MTI calls first because they may use
|
||||
// a bitcast/GEP of the alloca we are removing.
|
||||
if (!Users[i])
|
||||
continue;
|
||||
if (!User)
|
||||
continue;
|
||||
|
||||
Instruction *I = cast<Instruction>(&*Users[i]);
|
||||
Instruction *I = cast<Instruction>(&*User);
|
||||
|
||||
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
|
||||
if (II->getIntrinsicID() == Intrinsic::objectsize) {
|
||||
@@ -3511,7 +3511,7 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
|
||||
Worklist.add(Inserted);
|
||||
replaceInstUsesWith(*I, Result);
|
||||
eraseInstFromFunction(*I);
|
||||
Users[i] = nullptr; // Skip examining in the next loop.
|
||||
User = nullptr; // Skip examining in the next loop.
|
||||
continue;
|
||||
}
|
||||
if (auto *MTI = dyn_cast<MemTransferInst>(I)) {
|
||||
@@ -3527,11 +3527,11 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0, e = Users.size(); i != e; ++i) {
|
||||
if (!Users[i])
|
||||
for (WeakTrackingVH &User : Users) {
|
||||
if (!User)
|
||||
continue;
|
||||
|
||||
Instruction *I = cast<Instruction>(&*Users[i]);
|
||||
Instruction *I = cast<Instruction>(&*User);
|
||||
|
||||
if (ICmpInst *C = dyn_cast<ICmpInst>(I)) {
|
||||
replaceInstUsesWith(*C,
|
||||
|
||||
@@ -235,8 +235,8 @@ static bool populateDependencyMatrix(CharMatrix &DepMatrix, unsigned Level,
|
||||
// matrix by exchanging the two columns.
|
||||
static void interChangeDependencies(CharMatrix &DepMatrix, unsigned FromIndx,
|
||||
unsigned ToIndx) {
|
||||
for (unsigned I = 0, E = DepMatrix.size(); I < E; ++I)
|
||||
std::swap(DepMatrix[I][ToIndx], DepMatrix[I][FromIndx]);
|
||||
for (auto &Row : DepMatrix)
|
||||
std::swap(Row[ToIndx], Row[FromIndx]);
|
||||
}
|
||||
|
||||
// Check if a direction vector is lexicographically positive. Return true if it
|
||||
|
||||
@@ -83,10 +83,10 @@ static void PrintOps(Instruction *I, const SmallVectorImpl<ValueEntry> &Ops) {
|
||||
Module *M = I->getModule();
|
||||
dbgs() << Instruction::getOpcodeName(I->getOpcode()) << " "
|
||||
<< *Ops[0].Op->getType() << '\t';
|
||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||
for (const ValueEntry &Op : Ops) {
|
||||
dbgs() << "[ ";
|
||||
Ops[i].Op->printAsOperand(dbgs(), false, M);
|
||||
dbgs() << ", #" << Ops[i].Rank << "] ";
|
||||
Op.Op->printAsOperand(dbgs(), false, M);
|
||||
dbgs() << ", #" << Op.Rank << "] ";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1585,9 +1585,9 @@ Value *ReassociatePass::OptimizeAdd(Instruction *I,
|
||||
// where they are actually the same multiply.
|
||||
unsigned MaxOcc = 0;
|
||||
Value *MaxOccVal = nullptr;
|
||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||
for (const ValueEntry &Op : Ops) {
|
||||
BinaryOperator *BOp =
|
||||
isReassociableOp(Ops[i].Op, Instruction::Mul, Instruction::FMul);
|
||||
isReassociableOp(Op.Op, Instruction::Mul, Instruction::FMul);
|
||||
if (!BOp)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -3082,10 +3082,10 @@ bool VectorCombine::foldSelectShuffle(Instruction &I, bool FromReduction) {
|
||||
auto *SSV = cast<ShuffleVectorInst>(SVOp0);
|
||||
SVOp0 = SSV->getOperand(0);
|
||||
SVOp1 = SSV->getOperand(1);
|
||||
for (unsigned I = 0, E = Mask.size(); I != E; I++) {
|
||||
if (Mask[I] >= static_cast<int>(SSV->getShuffleMask().size()))
|
||||
for (int &Elem : Mask) {
|
||||
if (Elem >= static_cast<int>(SSV->getShuffleMask().size()))
|
||||
return false;
|
||||
Mask[I] = Mask[I] < 0 ? Mask[I] : SSV->getMaskValue(Mask[I]);
|
||||
Elem = Elem < 0 ? Elem : SSV->getMaskValue(Elem);
|
||||
}
|
||||
}
|
||||
if (SVOp0 == Op1 && SVOp1 == Op0) {
|
||||
|
||||
Reference in New Issue
Block a user