[llvm] 01b56b8 - [SCEVPredicateRewriter] Remove assumption top level predicate is a union [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 10 15:51:29 PST 2022
Author: Philip Reames
Date: 2022-02-10T15:51:15-08:00
New Revision: 01b56b8bddaee03ab5261e6bd67b9511dce00cd6
URL: https://github.com/llvm/llvm-project/commit/01b56b8bddaee03ab5261e6bd67b9511dce00cd6
DIFF: https://github.com/llvm/llvm-project/commit/01b56b8bddaee03ab5261e6bd67b9511dce00cd6.diff
LOG: [SCEVPredicateRewriter] Remove assumption top level predicate is a union [NFC]
Added:
Modified:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 36e4f84f39f6..30e62a640363 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -1176,7 +1176,7 @@ class ScalarEvolution {
/// 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(
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 1a31f96c1c24..a9e102a1056a 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -13634,19 +13634,25 @@ class SCEVPredicateRewriter : public SCEVRewriteVisitor<SCEVPredicateRewriter> {
/// \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 @@ class SCEVPredicateRewriter : public SCEVRewriteVisitor<SCEVPredicateRewriter> {
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 @@ class SCEVPredicateRewriter : public SCEVRewriteVisitor<SCEVPredicateRewriter> {
}
SmallPtrSetImpl<const SCEVPredicate *> *NewPreds;
- const SCEVUnionPredicate *Pred;
+ const SCEVPredicate *Pred;
const Loop *L;
};
@@ -13739,7 +13745,7 @@ class SCEVPredicateRewriter : public SCEVRewriteVisitor<SCEVPredicateRewriter> {
const SCEV *
ScalarEvolution::rewriteUsingPredicate(const SCEV *S, const Loop *L,
- const SCEVUnionPredicate &Preds) {
+ const SCEVPredicate &Preds) {
return SCEVPredicateRewriter::rewrite(S, L, *this, nullptr, &Preds);
}
More information about the llvm-commits
mailing list