[llvm] 35368bb - [NFC] Replace loop by idiomatic llvm::find_if
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 16 08:49:53 PDT 2021
Would llvm::any_of be even better?
~Craig
On Tue, Mar 16, 2021 at 4:49 AM via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
>
> 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();
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210316/30783b23/attachment.html>
More information about the llvm-commits
mailing list