summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/lib
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-11-22 15:47:44 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-11-22 15:47:44 +0000
commit840f03263072db90a20f636ab286b21523331ec6 (patch)
tree5da724e443f188ba037971ad2009255801415c38 /llvm/tools/llvm-mca/lib
parentc76394bc4b74b3104654ade5c0e87afcba13d6cd (diff)
downloadbcm5719-llvm-840f03263072db90a20f636ab286b21523331ec6.tar.gz
bcm5719-llvm-840f03263072db90a20f636ab286b21523331ec6.zip
[llvm-mca] LSUnit: use a SmallSet to model load/store queues. NFCI
Also, try to minimize the number of queries to the memory queues to speedup the analysis. On average, this change gives a small 2% speedup. For memcpy-like kernels, the speedup is up to 5.5%. llvm-svn: 347469
Diffstat (limited to 'llvm/tools/llvm-mca/lib')
-rw-r--r--llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp47
1 files changed, 27 insertions, 20 deletions
diff --git a/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp b/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp
index 6923c6e0dc8..ae020c68432 100644
--- a/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp
+++ b/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp
@@ -136,31 +136,38 @@ bool LSUnit::isReady(const InstRef &IR) const {
}
void LSUnit::onInstructionExecuted(const InstRef &IR) {
+ const InstrDesc &Desc = IR.getInstruction()->getDesc();
const unsigned Index = IR.getSourceIndex();
- std::set<unsigned>::iterator it = LoadQueue.find(Index);
- if (it != LoadQueue.end()) {
- LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
- << " has been removed from the load queue.\n");
- LoadQueue.erase(it);
- }
+ bool IsALoad = Desc.MayLoad;
+ bool IsAStore = Desc.MayStore;
- it = StoreQueue.find(Index);
- if (it != StoreQueue.end()) {
- LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
- << " has been removed from the store queue.\n");
- StoreQueue.erase(it);
+ if (IsALoad) {
+ if (LoadQueue.erase(Index)) {
+ LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
+ << " has been removed from the load queue.\n");
+ }
+ if (!LoadBarriers.empty() && Index == *LoadBarriers.begin()) {
+ LLVM_DEBUG(
+ dbgs() << "[LSUnit]: Instruction idx=" << Index
+ << " has been removed from the set of load barriers.\n");
+ LoadBarriers.erase(Index);
+ }
}
- if (!StoreBarriers.empty() && Index == *StoreBarriers.begin()) {
- LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
- << " has been removed from the set of store barriers.\n");
- StoreBarriers.erase(StoreBarriers.begin());
- }
- if (!LoadBarriers.empty() && Index == *LoadBarriers.begin()) {
- LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
- << " has been removed from the set of load barriers.\n");
- LoadBarriers.erase(LoadBarriers.begin());
+ if (IsAStore) {
+ if (StoreQueue.erase(Index)) {
+ LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
+ << " has been removed from the store queue.\n");
+ }
+
+ if (!StoreBarriers.empty() && Index == *StoreBarriers.begin()) {
+ LLVM_DEBUG(
+ dbgs() << "[LSUnit]: Instruction idx=" << Index
+ << " has been removed from the set of store barriers.\n");
+ StoreBarriers.erase(Index);
+ }
}
}
+
} // namespace mca
} // namespace llvm
OpenPOWER on IntegriCloud