[llvm] [CodeGen] Use range-based for loops (NFC) (PR #104536)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 18:46:56 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/104536
None
>From 7def48969de1d9851e5c7f5d988c2fd95e9e46a5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 15 Aug 2024 18:10:31 -0700
Subject: [PATCH] [CodeGen] Use range-based for loops (NFC)
---
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 4 ++--
llvm/lib/CodeGen/TypePromotion.cpp | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 219c60eab04f5a..8ceb729f0c156e 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -1463,8 +1463,8 @@ static uint64_t getOffsetFromIndices(const User &U, const DataLayout &DL) {
for (auto Idx : IVI->indices())
Indices.push_back(ConstantInt::get(Int32Ty, Idx));
} else {
- for (unsigned i = 1; i < U.getNumOperands(); ++i)
- Indices.push_back(U.getOperand(i));
+ for (Value *Op : drop_begin(U.operands()))
+ Indices.push_back(Op);
}
return 8 * static_cast<uint64_t>(
diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp
index 11aa3abe906853..b29c46b0540cdc 100644
--- a/llvm/lib/CodeGen/TypePromotion.cpp
+++ b/llvm/lib/CodeGen/TypePromotion.cpp
@@ -665,8 +665,8 @@ void IRPromoter::Mutate() {
} else if (auto *Switch = dyn_cast<SwitchInst>(I))
TruncTysMap[I].push_back(Switch->getCondition()->getType());
else {
- for (unsigned i = 0; i < I->getNumOperands(); ++i)
- TruncTysMap[I].push_back(I->getOperand(i)->getType());
+ for (const Value *Op : I->operands())
+ TruncTysMap[I].push_back(Op->getType());
}
}
for (auto *V : Visited) {
More information about the llvm-commits
mailing list