[llvm] 35368bb - [NFC] Replace loop by idiomatic llvm::find_if
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 16 04:49:30 PDT 2021
Author: serge-sans-paille
Date: 2021-03-16T12:49:19+01:00
New Revision: 35368bbdbb6f87543c3ea4c7f70c113954ce1bef
URL: https://github.com/llvm/llvm-project/commit/35368bbdbb6f87543c3ea4c7f70c113954ce1bef
DIFF: https://github.com/llvm/llvm-project/commit/35368bbdbb6f87543c3ea4c7f70c113954ce1bef.diff
LOG: [NFC] Replace loop by idiomatic llvm::find_if
Added:
Modified:
llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index a011b03d747c..bd20f32ee253 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -1357,11 +1357,9 @@ void
TwoAddressInstructionPass::processTiedPairs(MachineInstr *MI,
TiedPairList &TiedPairs,
unsigned &Dist) {
- bool IsEarlyClobber = false;
- for (unsigned tpi = 0, tpe = TiedPairs.size(); tpi != tpe; ++tpi) {
- const MachineOperand &DstMO = MI->getOperand(TiedPairs[tpi].second);
- IsEarlyClobber |= DstMO.isEarlyClobber();
- }
+ bool IsEarlyClobber = llvm::find_if(TiedPairs, [MI](auto const &TP) {
+ return MI->getOperand(TP.second).isEarlyClobber();
+ }) != TiedPairs.end();
bool RemovedKillFlag = false;
bool AllUsesCopied = true;
@@ -1369,9 +1367,9 @@ TwoAddressInstructionPass::processTiedPairs(MachineInstr *MI,
SlotIndex LastCopyIdx;
Register RegB = 0;
unsigned SubRegB = 0;
- for (unsigned tpi = 0, tpe = TiedPairs.size(); tpi != tpe; ++tpi) {
- unsigned SrcIdx = TiedPairs[tpi].first;
- unsigned DstIdx = TiedPairs[tpi].second;
+ for (auto &TP : TiedPairs) {
+ unsigned SrcIdx = TP.first;
+ unsigned DstIdx = TP.second;
const MachineOperand &DstMO = MI->getOperand(DstIdx);
Register RegA = DstMO.getReg();
More information about the llvm-commits
mailing list