Skip to content

Commit 91b2ac6

Browse files
[Transforms] Avoid repeated hash lookups (NFC) (#112654)
1 parent db32924 commit 91b2ac6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

llvm/lib/Transforms/Utils/LoopPeel.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,11 @@ PhiAnalyzer::PhiAnalyzer(const Loop &L, unsigned MaxIterations)
206206
// G(%y) = Unknown otherwise (including phi not in header block)
207207
PhiAnalyzer::PeelCounter PhiAnalyzer::calculate(const Value &V) {
208208
// If we already know the answer, take it from the map.
209-
auto I = IterationsToInvariance.find(&V);
210-
if (I != IterationsToInvariance.end())
211-
return I->second;
212-
213-
// Place Unknown to map to avoid infinite recursion. Such
209+
// Otherwise, place Unknown to map to avoid infinite recursion. Such
214210
// cycles can never stop on an invariant.
215-
IterationsToInvariance[&V] = Unknown;
211+
auto [I, Inserted] = IterationsToInvariance.try_emplace(&V, Unknown);
212+
if (!Inserted)
213+
return I->second;
216214

217215
if (L.isLoopInvariant(&V))
218216
// Loop invariant so known at start.

0 commit comments

Comments
 (0)