Skip to content

Commit 95dc5b8

Browse files
committed
[SCEV] Improve code in SCEVLoopGuardRewriter (NFC)
Prefer DenseMap::lookup over DenseMap::find.
1 parent 68dccb9 commit 95dc5b8

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15867,8 +15867,8 @@ const SCEV *ScalarEvolution::LoopGuards::rewrite(const SCEV *Expr) const {
1586715867
}
1586815868

1586915869
const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) {
15870-
auto I = Map.find(Expr);
15871-
if (I == Map.end()) {
15870+
const SCEV *S = Map.lookup(Expr);
15871+
if (!S) {
1587215872
// If we didn't find the extact ZExt expr in the map, check if there's
1587315873
// an entry for a smaller ZExt we can use instead.
1587415874
Type *Ty = Expr->getType();
@@ -15887,29 +15887,29 @@ const SCEV *ScalarEvolution::LoopGuards::rewrite(const SCEV *Expr) const {
1588715887
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitZeroExtendExpr(
1588815888
Expr);
1588915889
}
15890-
return I->second;
15890+
return S;
1589115891
}
1589215892

1589315893
const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *Expr) {
15894-
auto I = Map.find(Expr);
15895-
if (I == Map.end())
15894+
const SCEV *S = Map.lookup(Expr);
15895+
if (!S)
1589615896
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSignExtendExpr(
1589715897
Expr);
15898-
return I->second;
15898+
return S;
1589915899
}
1590015900

1590115901
const SCEV *visitUMinExpr(const SCEVUMinExpr *Expr) {
15902-
auto I = Map.find(Expr);
15903-
if (I == Map.end())
15902+
const SCEV *S = Map.lookup(Expr);
15903+
if (!S)
1590415904
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitUMinExpr(Expr);
15905-
return I->second;
15905+
return S;
1590615906
}
1590715907

1590815908
const SCEV *visitSMinExpr(const SCEVSMinExpr *Expr) {
15909-
auto I = Map.find(Expr);
15910-
if (I == Map.end())
15909+
const SCEV *S = Map.lookup(Expr);
15910+
if (!S)
1591115911
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSMinExpr(Expr);
15912-
return I->second;
15912+
return S;
1591315913
}
1591415914

1591515915
const SCEV *visitAddExpr(const SCEVAddExpr *Expr) {

0 commit comments

Comments
 (0)