[llvm] c63f823 - [llvm] Use range-based for loops (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 28 17:35:36 PDT 2022
Author: Kazu Hirata
Date: 2022-08-28T17:35:04-07:00
New Revision: c63f8238751b83a4d1b87e1f7076b0d9ce71d399
URL: https://github.com/llvm/llvm-project/commit/c63f8238751b83a4d1b87e1f7076b0d9ce71d399
DIFF: https://github.com/llvm/llvm-project/commit/c63f8238751b83a4d1b87e1f7076b0d9ce71d399.diff
LOG: [llvm] Use range-based for loops (NFC)
Added:
Modified:
llvm/lib/ObjCopy/MachO/MachOWriter.cpp
llvm/lib/Target/ARM/A15SDOptimizer.cpp
llvm/lib/Target/SystemZ/SystemZLDCleanup.cpp
llvm/lib/Target/X86/X86InterleavedAccess.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ObjCopy/MachO/MachOWriter.cpp b/llvm/lib/ObjCopy/MachO/MachOWriter.cpp
index bc633285e03c6..84db941fb4236 100644
--- a/llvm/lib/ObjCopy/MachO/MachOWriter.cpp
+++ b/llvm/lib/ObjCopy/MachO/MachOWriter.cpp
@@ -302,9 +302,8 @@ void MachOWriter::writeSymbolTable() {
.MachOLoadCommand.symtab_command_data;
char *SymTable = (char *)Buf->getBufferStart() + SymTabCommand.symoff;
- for (auto Iter = O.SymTable.Symbols.begin(), End = O.SymTable.Symbols.end();
- Iter != End; Iter++) {
- SymbolEntry *Sym = Iter->get();
+ for (auto &Symbol : O.SymTable.Symbols) {
+ SymbolEntry *Sym = Symbol.get();
uint32_t Nstrx = LayoutBuilder.getStringTableBuilder().getOffset(Sym->Name);
if (Is64Bit)
diff --git a/llvm/lib/Target/ARM/A15SDOptimizer.cpp b/llvm/lib/Target/ARM/A15SDOptimizer.cpp
index 65da95b0fc8de..9bced0661dff4 100644
--- a/llvm/lib/Target/ARM/A15SDOptimizer.cpp
+++ b/llvm/lib/Target/ARM/A15SDOptimizer.cpp
@@ -290,11 +290,11 @@ unsigned A15SDOptimizer::optimizeSDPattern(MachineInstr *MI) {
unsigned NumImplicit = 0, NumTotal = 0;
unsigned NonImplicitReg = ~0U;
- for (unsigned I = 1; I < MI->getNumExplicitOperands(); ++I) {
- if (!MI->getOperand(I).isReg())
+ for (MachineOperand &MO : llvm::drop_begin(MI->explicit_operands())) {
+ if (!MO.isReg())
continue;
++NumTotal;
- Register OpReg = MI->getOperand(I).getReg();
+ Register OpReg = MO.getReg();
if (!Register::isVirtualRegister(OpReg))
break;
@@ -305,7 +305,7 @@ unsigned A15SDOptimizer::optimizeSDPattern(MachineInstr *MI) {
if (Def->isImplicitDef())
++NumImplicit;
else
- NonImplicitReg = MI->getOperand(I).getReg();
+ NonImplicitReg = MO.getReg();
}
if (NumImplicit == NumTotal - 1)
diff --git a/llvm/lib/Target/SystemZ/SystemZLDCleanup.cpp b/llvm/lib/Target/SystemZ/SystemZLDCleanup.cpp
index 1e6f971906e9f..8073ed0e2a3c8 100644
--- a/llvm/lib/Target/SystemZ/SystemZLDCleanup.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZLDCleanup.cpp
@@ -105,8 +105,8 @@ bool SystemZLDCleanup::VisitNode(MachineDomTreeNode *Node,
}
// Visit the children of this block in the dominator tree.
- for (auto I = Node->begin(), E = Node->end(); I != E; ++I)
- Changed |= VisitNode(*I, TLSBaseAddrReg);
+ for (auto &N : *Node)
+ Changed |= VisitNode(N, TLSBaseAddrReg);
return Changed;
}
diff --git a/llvm/lib/Target/X86/X86InterleavedAccess.cpp b/llvm/lib/Target/X86/X86InterleavedAccess.cpp
index 40174a1297b77..8c31cf0c832df 100644
--- a/llvm/lib/Target/X86/X86InterleavedAccess.cpp
+++ b/llvm/lib/Target/X86/X86InterleavedAccess.cpp
@@ -264,10 +264,10 @@ static void genShuffleBland(MVT VT, ArrayRef<int> Mask,
assert(VT.getSizeInBits() >= 256 &&
"This function doesn't accept width smaller then 256");
unsigned NumOfElm = VT.getVectorNumElements();
- for (unsigned i = 0; i < Mask.size(); i++)
- Out.push_back(Mask[i] + LowOffset);
- for (unsigned i = 0; i < Mask.size(); i++)
- Out.push_back(Mask[i] + HighOffset + NumOfElm);
+ for (int I : Mask)
+ Out.push_back(I + LowOffset);
+ for (int I : Mask)
+ Out.push_back(I + HighOffset + NumOfElm);
}
// reorderSubVector returns the data to is the original state. And de-facto is
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index bac1dd25c85a9..4467a4f8a2668 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -1699,8 +1699,8 @@ static bool canEvaluateShuffled(Value *V, ArrayRef<int> Mask,
// Verify that 'CI' does not occur twice in Mask. A single 'insertelement'
// can't put an element into multiple indices.
bool SeenOnce = false;
- for (int i = 0, e = Mask.size(); i != e; ++i) {
- if (Mask[i] == ElementNumber) {
+ for (int I : Mask) {
+ if (I == ElementNumber) {
if (SeenOnce)
return false;
SeenOnce = true;
More information about the llvm-commits
mailing list