[llvm] [Analysis] Avoid repeated hash lookups (NFC) (PR #133045)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 25 23:57:07 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/133045.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+3-3)
``````````diff
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 314baa7c7aee1..69561472dc663 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -15443,9 +15443,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())));
``````````
</details>
https://github.com/llvm/llvm-project/pull/133045
More information about the llvm-commits
mailing list