Skip to content

Commit 78f6143

Browse files
committed
!fixup add LoopGuards class, move collect logic there.
1 parent bc6780b commit 78f6143

File tree

2 files changed

+189
-180
lines changed

2 files changed

+189
-180
lines changed

llvm/include/llvm/Analysis/ScalarEvolution.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,17 +1299,26 @@ class ScalarEvolution {
12991299
/// sharpen it.
13001300
void setNoWrapFlags(SCEVAddRecExpr *AddRec, SCEV::NoWrapFlags Flags);
13011301

1302-
/// Collect rewrite map for loop guards for loop \p L, together with flags
1303-
/// indidcating if NUW and NSW can be preserved during rewriting.
1304-
std::tuple<DenseMap<const SCEV *, const SCEV *>, bool, bool>
1305-
collectRewriteInfoFromLoopGuards(const Loop *L);
1302+
class LoopGuards {
1303+
DenseMap<const SCEV *, const SCEV *> RewriteMap;
1304+
bool PreserveNUW = false;
1305+
bool PreserveNSW = false;
1306+
ScalarEvolution &SE;
1307+
1308+
LoopGuards(ScalarEvolution &SE) : SE(SE) {}
1309+
1310+
public:
1311+
/// Collect rewrite map for loop guards for loop \p L, together with flags
1312+
/// indidcating if NUW and NSW can be preserved during rewriting.
1313+
static LoopGuards collect(const Loop *L, ScalarEvolution &SE);
1314+
1315+
/// Try to apply the collected loop guards to \p Expr
1316+
const SCEV *rewrite(const SCEV *Expr) const;
1317+
};
13061318

13071319
/// Try to apply information from loop guards for \p L to \p Expr.
13081320
const SCEV *applyLoopGuards(const SCEV *Expr, const Loop *L);
1309-
const SCEV *
1310-
applyLoopGuards(const SCEV *Expr, const Loop *L,
1311-
const DenseMap<const SCEV *, const SCEV *> &RewriteMap,
1312-
bool PreserveNUW, bool PreserveNSW);
1321+
const SCEV *applyLoopGuards(const SCEV *Expr, const LoopGuards &Gards);
13131322

13141323
/// Return true if the loop has no abnormal exits. That is, if the loop
13151324
/// is not infinite, it must exit through an explicit edge in the CFG.

0 commit comments

Comments
 (0)