[llvm] [Analysis] Simplify code with DenseMap::operator[] (NFC) (PR #111331)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 6 19:49:08 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/111331.diff
3 Files Affected:
- (modified) llvm/lib/Analysis/BasicAliasAnalysis.cpp (+2-4)
- (modified) llvm/lib/Analysis/LoopAccessAnalysis.cpp (+2-4)
- (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+1-2)
``````````diff
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index f471c0db11d3ef..1dcdad01f4c809 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -219,10 +219,8 @@ bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
Instruction *EarliestCapture = FindEarliestCapture(
Object, *const_cast<Function *>(DT.getRoot()->getParent()),
/*ReturnCaptures=*/false, /*StoreCaptures=*/true, DT);
- if (EarliestCapture) {
- auto Ins = Inst2Obj.insert({EarliestCapture, {}});
- Ins.first->second.push_back(Object);
- }
+ if (EarliestCapture)
+ Inst2Obj[EarliestCapture].push_back(Object);
Iter.first->second = EarliestCapture;
}
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index fe00ea0097a43a..d35bf6818d4379 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -512,10 +512,8 @@ void RuntimePointerChecking::groupChecks(
unsigned TotalComparisons = 0;
DenseMap<Value *, SmallVector<unsigned>> PositionMap;
- for (unsigned Index = 0; Index < Pointers.size(); ++Index) {
- auto [It, _] = PositionMap.insert({Pointers[Index].PointerValue, {}});
- It->second.push_back(Index);
- }
+ for (unsigned Index = 0; Index < Pointers.size(); ++Index)
+ PositionMap[Pointers[Index].PointerValue].push_back(Index);
// We need to keep track of what pointers we've already seen so we
// don't process them twice.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index c939270ed39a65..3d890f05c8ca21 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -1564,8 +1564,7 @@ static void insertFoldCacheEntry(
UserIDs.pop_back();
I.first->second = S;
}
- auto R = FoldCacheUser.insert({S, {}});
- R.first->second.push_back(ID);
+ FoldCacheUser[S].push_back(ID);
}
const SCEV *
``````````
</details>
https://github.com/llvm/llvm-project/pull/111331
More information about the llvm-commits
mailing list