Skip to content

Commit 3a98db6

Browse files
committed
!fixup update after rebase
1 parent 277d277 commit 3a98db6

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
@@ -16009,7 +16009,6 @@ const SCEV *ScalarEvolution::LoopGuards::rewrite(const SCEV *Expr) const {
1600916009
if (const SCEV *S = Map.lookup(Expr))
1601016010
return S;
1601116011

16012-
1601316012
// Helper to check if S is a subtraction (A - B) where A != B, and if so,
1601416013
// return UMax(S, 1).
1601516014
auto RewriteSubtraction = [&](const SCEV *S) -> const SCEV * {
@@ -16034,20 +16033,21 @@ const SCEV *ScalarEvolution::LoopGuards::rewrite(const SCEV *Expr) const {
1603416033
// (Const + A + B). There may be guard info for A + B, and if so, apply
1603516034
// it.
1603616035
// TODO: Could more generally apply guards to Add sub-expressions.
16037-
if (isa<SCEVConstant>(Expr->getOperand(0)) &&
16038-
Expr->getNumOperands() == 3) {
16039-
const SCEV *Add =
16040-
SE.getAddExpr(Expr->getOperand(1), Expr->getOperand(2));
16041-
if (const SCEV *Rewritten = RewriteSubtraction(Add))
16042-
return SE.getAddExpr(
16043-
Expr->getOperand(0), Rewritten,
16044-
ScalarEvolution::maskFlags(Expr->getNoWrapFlags(), FlagMask));
16045-
if (const SCEV *S = Map.lookup(Add))
16046-
return SE.getAddExpr(Expr->getOperand(0), S);
16036+
if (isa<SCEVConstant>(Expr->getOperand(0))) {
16037+
if (Expr->getNumOperands() == 3) {
16038+
const SCEV *Add =
16039+
SE.getAddExpr(Expr->getOperand(1), Expr->getOperand(2));
16040+
if (const SCEV *Rewritten = RewriteSubtraction(Add))
16041+
return SE.getAddExpr(
16042+
Expr->getOperand(0), Rewritten,
16043+
ScalarEvolution::maskFlags(Expr->getNoWrapFlags(), FlagMask));
16044+
if (const SCEV *S = Map.lookup(Add))
16045+
return SE.getAddExpr(Expr->getOperand(0), S);
16046+
}
1604716047

1604816048
// For expressions of the form (Const + A), check if we have guard info
1604916049
// for (Const + 1 + A), and rewrite to ((Const + 1 + A) - 1). This makes
16050-
// sure we don't loose information when rewriting expressions based on
16050+
// sure we don't lose information when rewriting expressions based on
1605116051
// back-edge taken counts in some cases.
1605216052
if (Expr->getNumOperands() == 2) {
1605316053
auto *NewC =

0 commit comments

Comments
 (0)