[llvm] [Transforms] Use range-based for loops (NFC) (PR #99607)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 22:25:58 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/99607.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Utils/LoopUnroll.cpp (+2-2)
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp (+3-3)
``````````diff
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index 0afa1ef780504..a0406111ecbf3 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -1091,8 +1091,8 @@ MDNode *llvm::GetUnrollMetadata(MDNode *LoopID, StringRef Name) {
assert(LoopID->getNumOperands() > 0 && "requires at least one operand");
assert(LoopID->getOperand(0) == LoopID && "invalid loop id");
- for (unsigned i = 1, e = LoopID->getNumOperands(); i < e; ++i) {
- MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i));
+ for (const MDOperand &MDO : llvm::drop_begin(LoopID->operands())) {
+ MDNode *MD = dyn_cast<MDNode>(MDO);
if (!MD)
continue;
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index f54eebb2874ab..cafec165f6d6f 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -261,20 +261,20 @@ void LoopVectorizeHints::getHintsFromMetadata() {
assert(LoopID->getNumOperands() > 0 && "requires at least one operand");
assert(LoopID->getOperand(0) == LoopID && "invalid loop id");
- for (unsigned i = 1, ie = LoopID->getNumOperands(); i < ie; ++i) {
+ for (const MDOperand &MDO : llvm::drop_begin(LoopID->operands())) {
const MDString *S = nullptr;
SmallVector<Metadata *, 4> Args;
// The expected hint is either a MDString or a MDNode with the first
// operand a MDString.
- if (const MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i))) {
+ if (const MDNode *MD = dyn_cast<MDNode>(MDO)) {
if (!MD || MD->getNumOperands() == 0)
continue;
S = dyn_cast<MDString>(MD->getOperand(0));
for (unsigned i = 1, ie = MD->getNumOperands(); i < ie; ++i)
Args.push_back(MD->getOperand(i));
} else {
- S = dyn_cast<MDString>(LoopID->getOperand(i));
+ S = dyn_cast<MDString>(MDO);
assert(Args.size() == 0 && "too many arguments for MDString");
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/99607
More information about the llvm-commits
mailing list