@@ -15867,49 +15867,45 @@ const SCEV *ScalarEvolution::LoopGuards::rewrite(const SCEV *Expr) const {
15867
15867
}
15868
15868
15869
15869
const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) {
15870
- auto I = Map.find(Expr);
15871
- if (I == Map.end()) {
15872
- // If we didn't find the extact ZExt expr in the map, check if there's
15873
- // an entry for a smaller ZExt we can use instead.
15874
- Type *Ty = Expr->getType();
15875
- const SCEV *Op = Expr->getOperand(0);
15876
- unsigned Bitwidth = Ty->getScalarSizeInBits() / 2;
15877
- while (Bitwidth % 8 == 0 && Bitwidth >= 8 &&
15878
- Bitwidth > Op->getType()->getScalarSizeInBits()) {
15879
- Type *NarrowTy = IntegerType::get(SE.getContext(), Bitwidth);
15880
- auto *NarrowExt = SE.getZeroExtendExpr(Op, NarrowTy);
15881
- auto I = Map.find(NarrowExt);
15882
- if (I != Map.end())
15883
- return SE.getZeroExtendExpr(I->second, Ty);
15884
- Bitwidth = Bitwidth / 2;
15885
- }
15870
+ if (const SCEV *S = Map.lookup(Expr))
15871
+ return S;
15886
15872
15887
- return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitZeroExtendExpr(
15888
- Expr);
15873
+ // If we didn't find the extact ZExt expr in the map, check if there's
15874
+ // an entry for a smaller ZExt we can use instead.
15875
+ Type *Ty = Expr->getType();
15876
+ const SCEV *Op = Expr->getOperand(0);
15877
+ unsigned Bitwidth = Ty->getScalarSizeInBits() / 2;
15878
+ while (Bitwidth % 8 == 0 && Bitwidth >= 8 &&
15879
+ Bitwidth > Op->getType()->getScalarSizeInBits()) {
15880
+ Type *NarrowTy = IntegerType::get(SE.getContext(), Bitwidth);
15881
+ auto *NarrowExt = SE.getZeroExtendExpr(Op, NarrowTy);
15882
+ auto I = Map.find(NarrowExt);
15883
+ if (I != Map.end())
15884
+ return SE.getZeroExtendExpr(I->second, Ty);
15885
+ Bitwidth = Bitwidth / 2;
15889
15886
}
15890
- return I->second;
15887
+
15888
+ return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitZeroExtendExpr(
15889
+ Expr);
15891
15890
}
15892
15891
15893
15892
const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *Expr) {
15894
- auto I = Map.find(Expr);
15895
- if (I == Map.end())
15896
- return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSignExtendExpr(
15897
- Expr);
15898
- return I->second;
15893
+ if (const SCEV *S = Map.lookup(Expr))
15894
+ return S;
15895
+ return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSignExtendExpr(
15896
+ Expr);
15899
15897
}
15900
15898
15901
15899
const SCEV *visitUMinExpr(const SCEVUMinExpr *Expr) {
15902
- auto I = Map.find(Expr);
15903
- if (I == Map.end())
15904
- return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitUMinExpr(Expr);
15905
- return I->second;
15900
+ if (const SCEV *S = Map.lookup(Expr))
15901
+ return S;
15902
+ return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitUMinExpr(Expr);
15906
15903
}
15907
15904
15908
15905
const SCEV *visitSMinExpr(const SCEVSMinExpr *Expr) {
15909
- auto I = Map.find(Expr);
15910
- if (I == Map.end())
15911
- return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSMinExpr(Expr);
15912
- return I->second;
15906
+ if (const SCEV *S = Map.lookup(Expr))
15907
+ return S;
15908
+ return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSMinExpr(Expr);
15913
15909
}
15914
15910
15915
15911
const SCEV *visitAddExpr(const SCEVAddExpr *Expr) {
0 commit comments