[PATCH] D73866: [RDA] getInstFromId: find instructions. NFC.
Sjoerd Meijer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 01:32:21 PST 2020
SjoerdMeijer created this revision.
SjoerdMeijer added a reviewer: samparker.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
To find the instruction in the block for a given ID, first a count and then a lookup was performed in the map, which is almost the same thing, thus doing double the work.
https://reviews.llvm.org/D73866
Files:
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
Index: llvm/lib/CodeGen/ReachingDefAnalysis.cpp
===================================================================
--- llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -214,10 +214,12 @@
if (InstId < 0)
return nullptr;
- for (auto &MI : *MBB) {
- if (InstIds.count(&MI) && InstIds.lookup(&MI) == InstId)
- return &MI;
- }
+ auto It = std::find_if(MBB->begin(), MBB->end(), [&](const MachineInstr &MI) {
+ return InstIds.lookup(&MI) == InstId;
+ });
+ if (It != MBB->end())
+ return &*It;
+
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73866.241989.patch
Type: text/x-patch
Size: 584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200203/30f468a7/attachment.bin>
More information about the llvm-commits
mailing list