[SCEVPredicateRewriter] Remove assumption top level predicate is a union [NFC]
This commit is contained in:
parent
2fa87ab524
commit
01b56b8bdd
@ -1176,7 +1176,7 @@ public:
|
||||
|
||||
/// Re-writes the SCEV according to the Predicates in \p A.
|
||||
const SCEV *rewriteUsingPredicate(const SCEV *S, const Loop *L,
|
||||
const SCEVUnionPredicate &A);
|
||||
const SCEVPredicate &A);
|
||||
/// Tries to convert the \p S expression to an AddRec expression,
|
||||
/// adding additional predicates to \p Preds as required.
|
||||
const SCEVAddRecExpr *convertSCEVToAddRecWithPredicates(
|
||||
|
@ -13634,19 +13634,25 @@ public:
|
||||
/// \p NewPreds such that the result will be an AddRecExpr.
|
||||
static const SCEV *rewrite(const SCEV *S, const Loop *L, ScalarEvolution &SE,
|
||||
SmallPtrSetImpl<const SCEVPredicate *> *NewPreds,
|
||||
const SCEVUnionPredicate *Pred) {
|
||||
const SCEVPredicate *Pred) {
|
||||
SCEVPredicateRewriter Rewriter(L, SE, NewPreds, Pred);
|
||||
return Rewriter.visit(S);
|
||||
}
|
||||
|
||||
const SCEV *visitUnknown(const SCEVUnknown *Expr) {
|
||||
if (Pred) {
|
||||
auto ExprPreds = Pred->getPredicatesForExpr(Expr);
|
||||
for (auto *Pred : ExprPreds)
|
||||
if (const auto *IPred = dyn_cast<SCEVComparePredicate>(Pred))
|
||||
if (IPred->getLHS() == Expr &&
|
||||
IPred->getPredicate() == ICmpInst::ICMP_EQ)
|
||||
return IPred->getRHS();
|
||||
if (auto *U = dyn_cast<SCEVUnionPredicate>(Pred)) {
|
||||
auto ExprPreds = U->getPredicatesForExpr(Expr);
|
||||
for (auto *Pred : ExprPreds)
|
||||
if (const auto *IPred = dyn_cast<SCEVComparePredicate>(Pred))
|
||||
if (IPred->getLHS() == Expr &&
|
||||
IPred->getPredicate() == ICmpInst::ICMP_EQ)
|
||||
return IPred->getRHS();
|
||||
} else if (const auto *IPred = dyn_cast<SCEVComparePredicate>(Pred)) {
|
||||
if (IPred->getLHS() == Expr &&
|
||||
IPred->getPredicate() == ICmpInst::ICMP_EQ)
|
||||
return IPred->getRHS();
|
||||
}
|
||||
}
|
||||
return convertToAddRecWithPreds(Expr);
|
||||
}
|
||||
@ -13686,7 +13692,7 @@ public:
|
||||
private:
|
||||
explicit SCEVPredicateRewriter(const Loop *L, ScalarEvolution &SE,
|
||||
SmallPtrSetImpl<const SCEVPredicate *> *NewPreds,
|
||||
const SCEVUnionPredicate *Pred)
|
||||
const SCEVPredicate *Pred)
|
||||
: SCEVRewriteVisitor(SE), NewPreds(NewPreds), Pred(Pred), L(L) {}
|
||||
|
||||
bool addOverflowAssumption(const SCEVPredicate *P) {
|
||||
@ -13731,7 +13737,7 @@ private:
|
||||
}
|
||||
|
||||
SmallPtrSetImpl<const SCEVPredicate *> *NewPreds;
|
||||
const SCEVUnionPredicate *Pred;
|
||||
const SCEVPredicate *Pred;
|
||||
const Loop *L;
|
||||
};
|
||||
|
||||
@ -13739,7 +13745,7 @@ private:
|
||||
|
||||
const SCEV *
|
||||
ScalarEvolution::rewriteUsingPredicate(const SCEV *S, const Loop *L,
|
||||
const SCEVUnionPredicate &Preds) {
|
||||
const SCEVPredicate &Preds) {
|
||||
return SCEVPredicateRewriter::rewrite(S, L, *this, nullptr, &Preds);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user