[llvm] b47849b - [SCEV] Avoid repeated hash lookups (NFC) (#112656)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 07:46:37 PDT 2024
Author: Kazu Hirata
Date: 2024-10-17T07:46:32-07:00
New Revision: b47849b4cb01a88371536ed660ff4f8aa01512b2
URL: https://github.com/llvm/llvm-project/commit/b47849b4cb01a88371536ed660ff4f8aa01512b2
DIFF: https://github.com/llvm/llvm-project/commit/b47849b4cb01a88371536ed660ff4f8aa01512b2.diff
LOG: [SCEV] Avoid repeated hash lookups (NFC) (#112656)
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 3d028ab752f2ce..58e23e9556f144 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -9662,14 +9662,14 @@ Constant *
ScalarEvolution::getConstantEvolutionLoopExitValue(PHINode *PN,
const APInt &BEs,
const Loop *L) {
- auto I = ConstantEvolutionLoopExitValue.find(PN);
- if (I != ConstantEvolutionLoopExitValue.end())
+ auto [I, Inserted] = ConstantEvolutionLoopExitValue.try_emplace(PN);
+ if (!Inserted)
return I->second;
if (BEs.ugt(MaxBruteForceIterations))
- return ConstantEvolutionLoopExitValue[PN] = nullptr; // Not going to evaluate it.
+ return nullptr; // Not going to evaluate it.
- Constant *&RetVal = ConstantEvolutionLoopExitValue[PN];
+ Constant *&RetVal = I->second;
DenseMap<Instruction *, Constant *> CurrentIterVals;
BasicBlock *Header = L->getHeader();
More information about the llvm-commits
mailing list