Skip to content

Commit 303825d

Browse files
[Analysis] Avoid repeated hash lookups (NFC) (#128394)
1 parent 9d1fbbd commit 303825d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,12 +1443,13 @@ void AccessAnalysis::processMemAccesses() {
14431443
UnderlyingObj->getType()->getPointerAddressSpace()))
14441444
continue;
14451445

1446-
UnderlyingObjToAccessMap::iterator Prev =
1447-
ObjToLastAccess.find(UnderlyingObj);
1448-
if (Prev != ObjToLastAccess.end())
1449-
DepCands.unionSets(Access, Prev->second);
1446+
auto [It, Inserted] =
1447+
ObjToLastAccess.try_emplace(UnderlyingObj, Access);
1448+
if (!Inserted) {
1449+
DepCands.unionSets(Access, It->second);
1450+
It->second = Access;
1451+
}
14501452

1451-
ObjToLastAccess[UnderlyingObj] = Access;
14521453
LLVM_DEBUG(dbgs() << " " << *UnderlyingObj << "\n");
14531454
}
14541455
}

0 commit comments

Comments
 (0)