[llvm] 356494c - [NFC][AMDGPU] Perform a single lookup in map in SIInsertWaitcnts::isPreheaderToFlush
Juan Manuel MARTINEZ CAAMAÑO via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 05:11:02 PDT 2023
Author: Juan Manuel MARTINEZ CAAMAÑO
Date: 2023-09-20T14:02:04+02:00
New Revision: 356494c36e716e3bf7820fa4e87ac732b4d87a5a
URL: https://github.com/llvm/llvm-project/commit/356494c36e716e3bf7820fa4e87ac732b4d87a5a
DIFF: https://github.com/llvm/llvm-project/commit/356494c36e716e3bf7820fa4e87ac732b4d87a5a.diff
LOG: [NFC][AMDGPU] Perform a single lookup in map in SIInsertWaitcnts::isPreheaderToFlush
Added:
Modified:
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 7358ad9bbc992ce..1628226563e185c 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -1720,26 +1720,25 @@ bool SIInsertWaitcnts::insertWaitcntInBlock(MachineFunction &MF,
// which we want to flush the vmcnt counter, and false otherwise.
bool SIInsertWaitcnts::isPreheaderToFlush(MachineBasicBlock &MBB,
WaitcntBrackets &ScoreBrackets) {
- if (PreheadersToFlush.count(&MBB))
- return PreheadersToFlush[&MBB];
-
- auto UpdateCache = [&](bool val) {
- PreheadersToFlush[&MBB] = val;
- return val;
- };
+ auto [Iterator, IsInserted] = PreheadersToFlush.try_emplace(&MBB, false);
+ if (!IsInserted)
+ return Iterator->second;
MachineBasicBlock *Succ = MBB.getSingleSuccessor();
if (!Succ)
- return UpdateCache(false);
+ return false;
MachineLoop *Loop = MLI->getLoopFor(Succ);
if (!Loop)
- return UpdateCache(false);
+ return false;
- if (Loop->getLoopPreheader() == &MBB && shouldFlushVmCnt(Loop, ScoreBrackets))
- return UpdateCache(true);
+ if (Loop->getLoopPreheader() == &MBB &&
+ shouldFlushVmCnt(Loop, ScoreBrackets)) {
+ Iterator->second = true;
+ return true;
+ }
- return UpdateCache(false);
+ return false;
}
bool SIInsertWaitcnts::isVMEMOrFlatVMEM(const MachineInstr &MI) const {
More information about the llvm-commits
mailing list