diff options
author | Kazu Hirata <kazu@google.com> | 2025-03-11 07:34:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-11 07:34:14 -0700 |
commit | 3339632e9c68ff71071b5ad72b33f7a8ac5658f6 (patch) | |
tree | 2bd7de5738accaa16ed3fff816f08cd3f98b1fa5 /llvm/lib/Transforms/Utils/LCSSA.cpp | |
parent | 8c2714e44802cb36eb556a3f2940bbc2e512f6be (diff) | |
download | llvm-3339632e9c68ff71071b5ad72b33f7a8ac5658f6.zip llvm-3339632e9c68ff71071b5ad72b33f7a8ac5658f6.tar.gz llvm-3339632e9c68ff71071b5ad72b33f7a8ac5658f6.tar.bz2 |
[Utils] Avoid repeated hash lookups (NFC) (#130709)
Diffstat (limited to 'llvm/lib/Transforms/Utils/LCSSA.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LCSSA.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/LCSSA.cpp b/llvm/lib/Transforms/Utils/LCSSA.cpp index d76a0c2..c3c3cdf 100644 --- a/llvm/lib/Transforms/Utils/LCSSA.cpp +++ b/llvm/lib/Transforms/Utils/LCSSA.cpp @@ -99,10 +99,10 @@ formLCSSAForInstructionsImpl(SmallVectorImpl<Instruction *> &Worklist, BasicBlock *InstBB = I->getParent(); Loop *L = LI.getLoopFor(InstBB); assert(L && "Instruction belongs to a BB that's not part of a loop"); - if (!LoopExitBlocks.count(L)) - L->getExitBlocks(LoopExitBlocks[L]); - assert(LoopExitBlocks.count(L)); - const SmallVectorImpl<BasicBlock *> &ExitBlocks = LoopExitBlocks[L]; + auto [It, Inserted] = LoopExitBlocks.try_emplace(L); + if (Inserted) + L->getExitBlocks(It->second); + const SmallVectorImpl<BasicBlock *> &ExitBlocks = It->second; if (ExitBlocks.empty()) continue; @@ -389,9 +389,10 @@ static bool formLCSSAImpl(Loop &L, const DominatorTree &DT, const LoopInfo *LI, } #endif - if (!LoopExitBlocks.count(&L)) - L.getExitBlocks(LoopExitBlocks[&L]); - const SmallVectorImpl<BasicBlock *> &ExitBlocks = LoopExitBlocks[&L]; + auto [It, Inserted] = LoopExitBlocks.try_emplace(&L); + if (Inserted) + L.getExitBlocks(It->second); + const SmallVectorImpl<BasicBlock *> &ExitBlocks = It->second; if (ExitBlocks.empty()) return false; |