[llvm] 8feb607 - [llvm] Use range-based for loops (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 28 23:29:21 PDT 2022
Author: Kazu Hirata
Date: 2022-08-28T23:28:58-07:00
New Revision: 8feb60756c7c5d083bf0396dcd6d34e84bca8bc1
URL: https://github.com/llvm/llvm-project/commit/8feb60756c7c5d083bf0396dcd6d34e84bca8bc1
DIFF: https://github.com/llvm/llvm-project/commit/8feb60756c7c5d083bf0396dcd6d34e84bca8bc1.diff
LOG: [llvm] Use range-based for loops (NFC)
Added:
Modified:
llvm/include/llvm/ProfileData/InstrProf.h
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index cce2a8faf4dda..8fe2821f65cba 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -636,8 +636,8 @@ struct CountSumOrPercent {
void reset() {
NumEntries = 0;
CountSum = 0.0f;
- for (unsigned I = 0; I < IPVK_Last - IPVK_First + 1; I++)
- ValueCounts[I] = 0.0f;
+ for (double &VC : ValueCounts)
+ VC = 0.0f;
}
};
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 56d72aba45dbf..5cb3f03f70b3d 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -7603,35 +7603,32 @@ SystemZTargetLowering::emitSelect(MachineInstr &MI,
SmallVector<MachineInstr*, 8> DbgValues;
Selects.push_back(&MI);
unsigned Count = 0;
- for (MachineBasicBlock::iterator NextMIIt =
- std::next(MachineBasicBlock::iterator(MI));
- NextMIIt != MBB->end(); ++NextMIIt) {
- if (isSelectPseudo(*NextMIIt)) {
- assert(NextMIIt->getOperand(3).getImm() == CCValid &&
+ for (MachineInstr &NextMI : llvm::make_range(
+ std::next(MachineBasicBlock::iterator(MI)), MBB->end())) {
+ if (isSelectPseudo(NextMI)) {
+ assert(NextMI.getOperand(3).getImm() == CCValid &&
"Bad CCValid operands since CC was not redefined.");
- if (NextMIIt->getOperand(4).getImm() == CCMask ||
- NextMIIt->getOperand(4).getImm() == (CCValid ^ CCMask)) {
- Selects.push_back(&*NextMIIt);
+ if (NextMI.getOperand(4).getImm() == CCMask ||
+ NextMI.getOperand(4).getImm() == (CCValid ^ CCMask)) {
+ Selects.push_back(&NextMI);
continue;
}
break;
}
- if (NextMIIt->definesRegister(SystemZ::CC) ||
- NextMIIt->usesCustomInsertionHook())
+ if (NextMI.definesRegister(SystemZ::CC) || NextMI.usesCustomInsertionHook())
break;
bool User = false;
for (auto *SelMI : Selects)
- if (NextMIIt->readsVirtualRegister(SelMI->getOperand(0).getReg())) {
+ if (NextMI.readsVirtualRegister(SelMI->getOperand(0).getReg())) {
User = true;
break;
}
- if (NextMIIt->isDebugInstr()) {
+ if (NextMI.isDebugInstr()) {
if (User) {
- assert(NextMIIt->isDebugValue() && "Unhandled debug opcode.");
- DbgValues.push_back(&*NextMIIt);
+ assert(NextMI.isDebugValue() && "Unhandled debug opcode.");
+ DbgValues.push_back(&NextMI);
}
- }
- else if (User || ++Count > 20)
+ } else if (User || ++Count > 20)
break;
}
diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
index 760a6f6823b06..2bb49091e2c15 100644
--- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
@@ -1878,16 +1878,15 @@ prepareCompareSwapOperands(MachineBasicBlock::iterator const MBBI) const {
MachineBasicBlock *MBB = MBBI->getParent();
bool CCLive = true;
SmallVector<MachineInstr *, 4> CCUsers;
- for (MachineBasicBlock::iterator Itr = std::next(MBBI);
- Itr != MBB->end(); ++Itr) {
- if (Itr->readsRegister(SystemZ::CC)) {
- unsigned Flags = Itr->getDesc().TSFlags;
+ for (MachineInstr &MI : llvm::make_range(std::next(MBBI), MBB->end())) {
+ if (MI.readsRegister(SystemZ::CC)) {
+ unsigned Flags = MI.getDesc().TSFlags;
if ((Flags & SystemZII::CCMaskFirst) || (Flags & SystemZII::CCMaskLast))
- CCUsers.push_back(&*Itr);
+ CCUsers.push_back(&MI);
else
return false;
}
- if (Itr->definesRegister(SystemZ::CC)) {
+ if (MI.definesRegister(SystemZ::CC)) {
CCLive = false;
break;
}
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 0c7f375141ff7..ba558f40c033e 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -49087,10 +49087,10 @@ static SDValue detectAVGPattern(SDValue In, EVT VT, SelectionDAG &DAG,
// Now we have three operands of two additions. Check that one of them is a
// constant vector with ones, and the other two can be promoted from i8/i16.
- for (int i = 0; i < 3; ++i) {
- if (!IsConstVectorInRange(Operands[i], 1, 1))
+ for (SDValue &Op : Operands) {
+ if (!IsConstVectorInRange(Op, 1, 1))
continue;
- std::swap(Operands[i], Operands[2]);
+ std::swap(Op, Operands[2]);
// Check if Operands[0] and Operands[1] are results of type promotion.
for (int j = 0; j < 2; ++j)
More information about the llvm-commits
mailing list