@@ -1559,9 +1559,8 @@ ScalarEvolution::getZeroExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth) {
1559
1559
Ty = getEffectiveSCEVType(Ty);
1560
1560
1561
1561
FoldID ID(scZeroExtend, Op, Ty);
1562
- auto Iter = FoldCache.find(ID);
1563
- if (Iter != FoldCache.end())
1564
- return Iter->second;
1562
+ if (const SCEV *S = FoldCache.lookup(ID))
1563
+ return S;
1565
1564
1566
1565
const SCEV *S = getZeroExtendExprImpl(Op, Ty, Depth);
1567
1566
if (!isa<SCEVZeroExtendExpr>(S))
@@ -1894,9 +1893,8 @@ ScalarEvolution::getSignExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth) {
1894
1893
Ty = getEffectiveSCEVType(Ty);
1895
1894
1896
1895
FoldID ID(scSignExtend, Op, Ty);
1897
- auto Iter = FoldCache.find(ID);
1898
- if (Iter != FoldCache.end())
1899
- return Iter->second;
1896
+ if (const SCEV *S = FoldCache.lookup(ID))
1897
+ return S;
1900
1898
1901
1899
const SCEV *S = getSignExtendExprImpl(Op, Ty, Depth);
1902
1900
if (!isa<SCEVSignExtendExpr>(S))
@@ -14498,15 +14496,15 @@ void ScalarEvolution::verify() const {
14498
14496
14499
14497
for (const auto &KV : ExprValueMap) {
14500
14498
for (Value *V : KV.second) {
14501
- auto It = ValueExprMap.find_as (V);
14502
- if (It == ValueExprMap.end() ) {
14499
+ const SCEV *S = ValueExprMap.lookup (V);
14500
+ if (!S ) {
14503
14501
dbgs() << "Value " << *V
14504
14502
<< " is in ExprValueMap but not in ValueExprMap\n";
14505
14503
std::abort();
14506
14504
}
14507
- if (It->second != KV.first) {
14508
- dbgs() << "Value " << *V << " mapped to " << *It->second
14509
- << " rather than " << *KV.first << "\n";
14505
+ if (S != KV.first) {
14506
+ dbgs() << "Value " << *V << " mapped to " << *S << " rather than "
14507
+ << *KV.first << "\n";
14510
14508
std::abort();
14511
14509
}
14512
14510
}
@@ -14625,15 +14623,15 @@ void ScalarEvolution::verify() const {
14625
14623
}
14626
14624
for (auto [Expr, IDs] : FoldCacheUser) {
14627
14625
for (auto &FoldID : IDs) {
14628
- auto I = FoldCache.find (FoldID);
14629
- if (I == FoldCache.end() ) {
14626
+ const SCEV *S = FoldCache.lookup (FoldID);
14627
+ if (!S ) {
14630
14628
dbgs() << "Missing entry in FoldCache for expression " << *Expr
14631
14629
<< "!\n";
14632
14630
std::abort();
14633
14631
}
14634
- if (I->second != Expr) {
14635
- dbgs() << "Entry in FoldCache doesn't match FoldCacheUser: "
14636
- << *I->second << " != " << *Expr << "!\n";
14632
+ if (S != Expr) {
14633
+ dbgs() << "Entry in FoldCache doesn't match FoldCacheUser: " << *S
14634
+ << " != " << *Expr << "!\n";
14637
14635
std::abort();
14638
14636
}
14639
14637
}
@@ -15601,8 +15599,7 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
15601
15599
// existing rewrite because we want to chain further rewrites onto the
15602
15600
// already rewritten value. Otherwise returns \p S.
15603
15601
auto GetMaybeRewritten = [&](const SCEV *S) {
15604
- auto I = RewriteMap.find(S);
15605
- return I != RewriteMap.end() ? I->second : S;
15602
+ return RewriteMap.lookup_or(S, S);
15606
15603
};
15607
15604
15608
15605
// Check for the SCEV expression (A /u B) * B while B is a constant, inside
@@ -15905,9 +15902,8 @@ const SCEV *ScalarEvolution::LoopGuards::rewrite(const SCEV *Expr) const {
15905
15902
Bitwidth > Op->getType()->getScalarSizeInBits()) {
15906
15903
Type *NarrowTy = IntegerType::get(SE.getContext(), Bitwidth);
15907
15904
auto *NarrowExt = SE.getZeroExtendExpr(Op, NarrowTy);
15908
- auto I = Map.find(NarrowExt);
15909
- if (I != Map.end())
15910
- return SE.getZeroExtendExpr(I->second, Ty);
15905
+ if (const SCEV *S = Map.lookup(NarrowExt))
15906
+ return SE.getZeroExtendExpr(S, Ty);
15911
15907
Bitwidth = Bitwidth / 2;
15912
15908
}
15913
15909
0 commit comments