Skip to content

Commit 488abd3

Browse files
kazutakahiratayuxuanchen1997
authored andcommitted
[Transforms] Use range-based for loops (NFC) (#99607)
1 parent a3ed16c commit 488abd3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/lib/Transforms/Utils/LoopUnroll.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,8 @@ MDNode *llvm::GetUnrollMetadata(MDNode *LoopID, StringRef Name) {
10911091
assert(LoopID->getNumOperands() > 0 && "requires at least one operand");
10921092
assert(LoopID->getOperand(0) == LoopID && "invalid loop id");
10931093

1094-
for (unsigned i = 1, e = LoopID->getNumOperands(); i < e; ++i) {
1095-
MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i));
1094+
for (const MDOperand &MDO : llvm::drop_begin(LoopID->operands())) {
1095+
MDNode *MD = dyn_cast<MDNode>(MDO);
10961096
if (!MD)
10971097
continue;
10981098

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,20 +261,20 @@ void LoopVectorizeHints::getHintsFromMetadata() {
261261
assert(LoopID->getNumOperands() > 0 && "requires at least one operand");
262262
assert(LoopID->getOperand(0) == LoopID && "invalid loop id");
263263

264-
for (unsigned i = 1, ie = LoopID->getNumOperands(); i < ie; ++i) {
264+
for (const MDOperand &MDO : llvm::drop_begin(LoopID->operands())) {
265265
const MDString *S = nullptr;
266266
SmallVector<Metadata *, 4> Args;
267267

268268
// The expected hint is either a MDString or a MDNode with the first
269269
// operand a MDString.
270-
if (const MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i))) {
270+
if (const MDNode *MD = dyn_cast<MDNode>(MDO)) {
271271
if (!MD || MD->getNumOperands() == 0)
272272
continue;
273273
S = dyn_cast<MDString>(MD->getOperand(0));
274274
for (unsigned i = 1, ie = MD->getNumOperands(); i < ie; ++i)
275275
Args.push_back(MD->getOperand(i));
276276
} else {
277-
S = dyn_cast<MDString>(LoopID->getOperand(i));
277+
S = dyn_cast<MDString>(MDO);
278278
assert(Args.size() == 0 && "too many arguments for MDString");
279279
}
280280

0 commit comments

Comments
 (0)