diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 57e6353e60a1410..915e914d6b9287b 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -994,9 +994,10 @@ class EmitterBase { const VectorType *getVectorType(const ScalarType *ST, unsigned Lanes) { std::tuple key(ST->kind(), ST->sizeInBits(), Lanes); - if (VectorTypes.find(key) == VectorTypes.end()) - VectorTypes[key] = std::make_unique(ST, Lanes); - return VectorTypes[key].get(); + auto [It, Inserted] = VectorTypes.try_emplace(key); + if (Inserted) + It->second = std::make_unique(ST, Lanes); + return It->second.get(); } const VectorType *getVectorType(const ScalarType *ST) { return getVectorType(ST, 128 / ST->sizeInBits()); @@ -1004,22 +1005,25 @@ class EmitterBase { const MultiVectorType *getMultiVectorType(unsigned Registers, const VectorType *VT) { std::pair key(VT->cNameBase(), Registers); - if (MultiVectorTypes.find(key) == MultiVectorTypes.end()) - MultiVectorTypes[key] = std::make_unique(Registers, VT); - return MultiVectorTypes[key].get(); + auto [It, Inserted] = MultiVectorTypes.try_emplace(key); + if (Inserted) + It->second = std::make_unique(Registers, VT); + return It->second.get(); } const PredicateType *getPredicateType(unsigned Lanes) { unsigned key = Lanes; - if (PredicateTypes.find(key) == PredicateTypes.end()) - PredicateTypes[key] = std::make_unique(Lanes); - return PredicateTypes[key].get(); + auto [It, Inserted] = PredicateTypes.try_emplace(key); + if (Inserted) + It->second = std::make_unique(Lanes); + return It->second.get(); } const PointerType *getPointerType(const Type *T, bool Const) { PointerType PT(T, Const); std::string key = PT.cName(); - if (PointerTypes.find(key) == PointerTypes.end()) - PointerTypes[key] = std::make_unique(PT); - return PointerTypes[key].get(); + auto [It, Inserted] = PointerTypes.try_emplace(key); + if (Inserted) + It->second = std::make_unique(PT); + return It->second.get(); } // Methods to construct a type from various pieces of Tablegen. These are