[llvm] [LoopUnroll] Use DenseMap::contains instead of count (NFC) (PR #224529)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 18 01:48:23 PDT 2026
https://github.com/xgxanq updated https://github.com/llvm/llvm-project/pull/224529
>From e989d0abdeacc31b865657cba9280727ffc160da Mon Sep 17 00:00:00 2001
From: anqfu <anqfu at amd.com>
Date: Fri, 18 Sep 2026 05:58:49 +0000
Subject: [PATCH] [LoopUnroll] Use DenseMap::contains instead of count (NFC)
Replace count()-then-lookup style membership checks with contains() in
analyzeLoopUnrollCost for readability.
---
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index ad3b123f3327c..e687aa32b1e88 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -515,7 +515,7 @@ static std::optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
Value *V = PHI->getIncomingValueForBlock(
Iteration == 0 ? L->getLoopPreheader() : L->getLoopLatch());
- if (Iteration != 0 && SimplifiedValues.count(V))
+ if (Iteration != 0 && SimplifiedValues.contains(V))
V = SimplifiedValues.lookup(V);
SimplifiedInputValues.push_back({PHI, V});
}
@@ -539,7 +539,7 @@ static std::optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
for (Instruction &I : *BB) {
// These won't get into the final code - don't even try calculating the
// cost for them.
- if (EphValues.count(&I))
+ if (EphValues.contains(&I))
continue;
// Track this instruction's expected baseline cost when executing the
@@ -590,7 +590,7 @@ static std::optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
Instruction *TI = BB->getTerminator();
auto getSimplifiedConstant = [&](Value *V) -> Constant * {
- if (SimplifiedValues.count(V))
+ if (SimplifiedValues.contains(V))
V = SimplifiedValues.lookup(V);
return dyn_cast<Constant>(V);
};
More information about the llvm-commits
mailing list