Skip to content

Commit 2f55e55

Browse files
[Transforms] Use range-based for loops (NFC) (#98725)
1 parent ca4ebae commit 2f55e55

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5953,8 +5953,8 @@ void LSRInstance::RewriteForPHI(
59535953
// formulae will not be implemented completely and some instructions
59545954
// will not be eliminated.
59555955
if (needUpdateFixups) {
5956-
for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx)
5957-
for (LSRFixup &Fixup : Uses[LUIdx].Fixups)
5956+
for (LSRUse &LU : Uses)
5957+
for (LSRFixup &Fixup : LU.Fixups)
59585958
// If fixup is supposed to rewrite some operand in the phi
59595959
// that was just updated, it may be already moved to
59605960
// another phi node. Such fixup requires update.

llvm/lib/Transforms/Scalar/Reassociate.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ void ReassociatePass::RewriteExprTree(BinaryOperator *I,
596596
/// of leaf nodes as inner nodes cannot occur by remembering all of the future
597597
/// leaves and refusing to reuse any of them as inner nodes.
598598
SmallPtrSet<Value*, 8> NotRewritable;
599-
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
600-
NotRewritable.insert(Ops[i].Op);
599+
for (const ValueEntry &Op : Ops)
600+
NotRewritable.insert(Op.Op);
601601

602602
// ExpressionChangedStart - Non-null if the rewritten expression differs from
603603
// the original in some non-trivial way, requiring the clearing of optional
@@ -762,8 +762,8 @@ void ReassociatePass::RewriteExprTree(BinaryOperator *I,
762762
}
763763

764764
// Throw away any left over nodes from the original expression.
765-
for (unsigned i = 0, e = NodesToRewrite.size(); i != e; ++i)
766-
RedoInsts.insert(NodesToRewrite[i]);
765+
for (BinaryOperator *BO : NodesToRewrite)
766+
RedoInsts.insert(BO);
767767
}
768768

769769
/// Insert instructions before the instruction pointed to by BI,
@@ -1988,8 +1988,8 @@ void ReassociatePass::EraseInst(Instruction *I) {
19881988
I->eraseFromParent();
19891989
// Optimize its operands.
19901990
SmallPtrSet<Instruction *, 8> Visited; // Detect self-referential nodes.
1991-
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
1992-
if (Instruction *Op = dyn_cast<Instruction>(Ops[i])) {
1991+
for (Value *V : Ops)
1992+
if (Instruction *Op = dyn_cast<Instruction>(V)) {
19931993
// If this is a node in an expression tree, climb to the expression root
19941994
// and add that since that's where optimization actually happens.
19951995
unsigned Opcode = Op->getOpcode();

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,10 +1815,9 @@ static void fixupLineNumbers(Function *Fn, Function::iterator FI,
18151815

18161816
// Iterate over all instructions, updating metadata and debug-info records.
18171817
for (; FI != Fn->end(); ++FI) {
1818-
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE;
1819-
++BI) {
1820-
UpdateInst(*BI);
1821-
for (DbgRecord &DVR : BI->getDbgRecordRange()) {
1818+
for (Instruction &I : *FI) {
1819+
UpdateInst(I);
1820+
for (DbgRecord &DVR : I.getDbgRecordRange()) {
18221821
UpdateDVR(&DVR);
18231822
}
18241823
}

0 commit comments

Comments
 (0)