[llvm] fe3e9c2 - [Analysis] Avoid repeated hash lookups (NFC) (#133045)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 31 23:17:48 PDT 2025
Author: Kazu Hirata
Date: 2025-03-31T23:17:44-07:00
New Revision: fe3e9c2b46504e7b197245b3946abfec563e77d4
URL: https://github.com/llvm/llvm-project/commit/fe3e9c2b46504e7b197245b3946abfec563e77d4
DIFF: https://github.com/llvm/llvm-project/commit/fe3e9c2b46504e7b197245b3946abfec563e77d4.diff
LOG: [Analysis] Avoid repeated hash lookups (NFC) (#133045)
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 361206719287a..14f9a1bec8939 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -15440,9 +15440,9 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
// Bail out, unless we have a non-wrapping, monotonic range.
if (ExactRegion.isWrappedSet() || ExactRegion.isFullSet())
return false;
- auto I = RewriteMap.find(LHSUnknown);
- const SCEV *RewrittenLHS = I != RewriteMap.end() ? I->second : LHSUnknown;
- RewriteMap[LHSUnknown] = SE.getUMaxExpr(
+ auto [I, Inserted] = RewriteMap.try_emplace(LHSUnknown);
+ const SCEV *RewrittenLHS = Inserted ? LHSUnknown : I->second;
+ I->second = SE.getUMaxExpr(
SE.getConstant(ExactRegion.getUnsignedMin()),
SE.getUMinExpr(RewrittenLHS,
SE.getConstant(ExactRegion.getUnsignedMax())));
More information about the llvm-commits
mailing list