aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/PredicateInfo.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-06-19 16:17:54 +0200
committerNikita Popov <npopov@redhat.com>2025-06-19 16:18:29 +0200
commit802fa92aee3565768887615108aa3e924d4e0fc7 (patch)
tree690ee83fe14ef55e394fe0676b132b6dc8cb109c /llvm/lib/Transforms/Utils/PredicateInfo.cpp
parenta4e4527c4b44be9a88168c0a4758de58fd1a770d (diff)
downloadllvm-802fa92aee3565768887615108aa3e924d4e0fc7.zip
llvm-802fa92aee3565768887615108aa3e924d4e0fc7.tar.gz
llvm-802fa92aee3565768887615108aa3e924d4e0fc7.tar.bz2
[PredicateInfo] Avoid duplicate hash lookup (NFC)
Use try_emplace to either look up the existing entry or insert it.
Diffstat (limited to 'llvm/lib/Transforms/Utils/PredicateInfo.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/PredicateInfo.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index d4b2bcf..4c87bab 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -728,16 +728,12 @@ void PredicateInfoBuilder::renameUses(SmallVectorImpl<Value *> &OpsToRename) {
PredicateInfoBuilder::ValueInfo &
PredicateInfoBuilder::getOrCreateValueInfo(Value *Operand) {
- auto OIN = ValueInfoNums.find(Operand);
- if (OIN == ValueInfoNums.end()) {
- // This will grow it
+ auto Res = ValueInfoNums.try_emplace(Operand, ValueInfos.size());
+ if (Res.second) {
+ // Allocate space for new ValueInfo.
ValueInfos.resize(ValueInfos.size() + 1);
- // This will use the new size and give us a 0 based number of the info
- auto InsertResult = ValueInfoNums.insert({Operand, ValueInfos.size() - 1});
- assert(InsertResult.second && "Value info number already existed?");
- return ValueInfos[InsertResult.first->second];
}
- return ValueInfos[OIN->second];
+ return ValueInfos[Res.first->second];
}
const PredicateInfoBuilder::ValueInfo &