[llvm] [BPI] Cache LoopExitBlocks to improve compile time (PR #93451)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 27 04:42:11 PDT 2024
================
@@ -828,12 +828,13 @@ void BranchProbabilityInfo::computeEestimateBlockWeight(
do {
while (!LoopWorkList.empty()) {
const LoopBlock LoopBB = LoopWorkList.pop_back_val();
-
- if (EstimatedLoopWeight.count(LoopBB.getLoopData()))
+ const LoopData LD = LoopBB.getLoopData();
+ if (EstimatedLoopWeight.count(LD))
continue;
- SmallVector<BasicBlock *, 4> Exits;
- getLoopExitBlocks(LoopBB, Exits);
+ if (!LoopExitBlocks.count(LD))
----------------
Enna1 wrote:
Sorry, I don't quite get it.
What do you think of using `try_emplace()` ?
```cpp
auto Res = LoopExitBlocks.try_emplace(LD);
SmallVectorImpl<BasicBlock *> &Exits = Res.first->second;
if (Res.second)
getLoopExitBlocks(LoopBB, Exits);
auto LoopWeight = getMaxEstimatedEdgeWeight(
LoopBB, make_range(Exits.begin(), Exits.end()));
```
https://github.com/llvm/llvm-project/pull/93451
More information about the llvm-commits
mailing list