Skip to content

Commit 546d03c

Browse files
[Hexagon] Avoid repeated hash lookups (NFC) (#125459)
1 parent 8686e67 commit 546d03c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,14 +1388,12 @@ bool PolynomialMultiplyRecognize::convertShiftsToLeft(BasicBlock *LoopB,
13881388

13891389
CastMapType CastMap;
13901390

1391-
auto upcast = [] (CastMapType &CM, IRBuilder<> &IRB, Value *V,
1392-
IntegerType *Ty) -> Value* {
1393-
auto H = CM.find(std::make_pair(V, Ty));
1394-
if (H != CM.end())
1395-
return H->second;
1396-
Value *CV = IRB.CreateIntCast(V, Ty, false);
1397-
CM.insert(std::make_pair(std::make_pair(V, Ty), CV));
1398-
return CV;
1391+
auto upcast = [](CastMapType &CM, IRBuilder<> &IRB, Value *V,
1392+
IntegerType *Ty) -> Value * {
1393+
auto [H, Inserted] = CM.try_emplace(std::make_pair(V, Ty));
1394+
if (Inserted)
1395+
H->second = IRB.CreateIntCast(V, Ty, false);
1396+
return H->second;
13991397
};
14001398

14011399
for (auto I = LoopB->begin(), E = LoopB->end(); I != E; ++I) {

0 commit comments

Comments
 (0)