[polly] r247731 - Use blocks instead of domains in SCEVAffinator
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 15:49:05 PDT 2015
Author: jdoerfert
Date: Tue Sep 15 17:49:04 2015
New Revision: 247731
URL: http://llvm.org/viewvc/llvm-project?rev=247731&view=rev
Log:
Use blocks instead of domains in SCEVAffinator
Due to the new domain generation, the SCoP keeps track of the domain
for all blocks, thus the SCEVAffinator can now work with blocks to avoid
duplication of the domains.
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/include/polly/Support/SCEVAffinator.h
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/lib/Support/SCEVAffinator.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=247731&r1=247730&r2=247731&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Tue Sep 15 17:49:04 2015
@@ -1325,17 +1325,21 @@ public:
/// @brief Compute the isl representation for the SCEV @p
///
- /// @param Domain An (optional) domain in which the isl_pw_aff is computed.
- /// SCEVs known to not reference any loops in the SCoP can be
- /// passed without a @p Domain.
- __isl_give isl_pw_aff *getPwAff(const SCEV *E,
- __isl_keep isl_set *Domain = nullptr);
+ /// @param BB An (optional) basic block in which the isl_pw_aff is computed.
+ /// SCEVs known to not reference any loops in the SCoP can be
+ /// passed without a @p BB.
+ __isl_give isl_pw_aff *getPwAff(const SCEV *E, BasicBlock *BB = nullptr);
/// @brief Return the non-loop carried conditions on the domain of @p Stmt.
///
/// @param Stmt The statement for which the conditions should be returned.
__isl_give isl_set *getDomainConditions(ScopStmt *Stmt);
+ /// @brief Return the non-loop carried conditions on the domain of @p BB.
+ ///
+ /// @param BB The block for which the conditions should be returned.
+ __isl_give isl_set *getDomainConditions(BasicBlock *BB);
+
/// @brief Get a union set containing the iteration domains of all statements.
__isl_give isl_union_set *getDomains() const;
Modified: polly/trunk/include/polly/Support/SCEVAffinator.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/SCEVAffinator.h?rev=247731&r1=247730&r2=247731&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/SCEVAffinator.h (original)
+++ polly/trunk/include/polly/Support/SCEVAffinator.h Tue Sep 15 17:49:04 2015
@@ -34,6 +34,7 @@ struct isl_schedule;
namespace llvm {
class Region;
+class BasicBlock;
class ScalarEvolution;
}
@@ -49,16 +50,16 @@ public:
/// @brief Translate a SCEV to an isl_pw_aff.
///
- /// @param E The expression that is translated.
- /// @param Domain The domain in which @p E is executed.
+ /// @param E he expression that is translated.
+ /// @param BB The block in which @p E is executed.
///
/// @returns The isl representation of the SCEV @p E in @p Domain.
__isl_give isl_pw_aff *getPwAff(const llvm::SCEV *E,
- __isl_keep isl_set *Domain = nullptr);
+ llvm::BasicBlock *BB = nullptr);
private:
/// @brief Key to identify cached expressions.
- using CacheKey = std::pair<const llvm::SCEV *, isl_set *>;
+ using CacheKey = std::pair<const llvm::SCEV *, llvm::BasicBlock *>;
/// @brief Map to remembered cached expressions.
llvm::DenseMap<CacheKey, isl_pw_aff *> CachedExpressions;
@@ -68,7 +69,7 @@ private:
unsigned NumIterators;
const llvm::Region &R;
llvm::ScalarEvolution &SE;
- isl_set *Domain;
+ llvm::BasicBlock *BB;
__isl_give isl_pw_aff *visit(const llvm::SCEV *E);
__isl_give isl_pw_aff *visitConstant(const llvm::SCEVConstant *E);
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=247731&r1=247730&r2=247731&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Sep 15 17:49:04 2015
@@ -729,7 +729,8 @@ isl_map *ScopStmt::getSchedule() const {
}
__isl_give isl_pw_aff *ScopStmt::getPwAff(const SCEV *E) {
- return getParent()->getPwAff(E, Domain);
+ return getParent()->getPwAff(E, isBlockStmt() ? getBasicBlock()
+ : getRegion()->getEntry());
}
void ScopStmt::restrictDomain(__isl_take isl_set *NewDomain) {
@@ -888,9 +889,10 @@ buildConditionSets(Scop &S, BranchInst *
"Condition of exiting branch was neither constant nor ICmp!");
ScalarEvolution &SE = *S.getSE();
+ BasicBlock *BB = BI->getParent();
isl_pw_aff *LHS, *RHS;
- LHS = S.getPwAff(SE.getSCEVAtScope(ICond->getOperand(0), L), Domain);
- RHS = S.getPwAff(SE.getSCEVAtScope(ICond->getOperand(1), L), Domain);
+ LHS = S.getPwAff(SE.getSCEVAtScope(ICond->getOperand(0), L), BB);
+ RHS = S.getPwAff(SE.getSCEVAtScope(ICond->getOperand(1), L), BB);
ConsequenceCondSet = buildConditionSet(ICond->getPredicate(), LHS, RHS);
for (unsigned u = 0, e = isl_set_n_dim(Domain); u < e; u++) {
@@ -1500,6 +1502,11 @@ static inline __isl_give isl_set *addDom
isl_set *Scop::getDomainConditions(ScopStmt *Stmt) {
BasicBlock *BB = Stmt->isBlockStmt() ? Stmt->getBasicBlock()
: Stmt->getRegion()->getEntry();
+ return getDomainConditions(BB);
+}
+
+isl_set *Scop::getDomainConditions(BasicBlock *BB) {
+ assert(DomainMap.count(BB) && "Requested BB did not have a domain");
return isl_set_copy(DomainMap[BB]);
}
@@ -2321,8 +2328,8 @@ void Scop::dump() const { print(dbgs());
isl_ctx *Scop::getIslCtx() const { return IslCtx; }
-__isl_give isl_pw_aff *Scop::getPwAff(const SCEV *E, isl_set *Domain) {
- return Affinator.getPwAff(E, Domain);
+__isl_give isl_pw_aff *Scop::getPwAff(const SCEV *E, BasicBlock *BB) {
+ return Affinator.getPwAff(E, BB);
}
__isl_give isl_union_set *Scop::getDomains() const {
Modified: polly/trunk/lib/Support/SCEVAffinator.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/SCEVAffinator.cpp?rev=247731&r1=247730&r2=247731&view=diff
==============================================================================
--- polly/trunk/lib/Support/SCEVAffinator.cpp (original)
+++ polly/trunk/lib/Support/SCEVAffinator.cpp Tue Sep 15 17:49:04 2015
@@ -30,19 +30,19 @@ SCEVAffinator::SCEVAffinator(Scop *S)
: S(S), Ctx(S->getIslCtx()), R(S->getRegion()), SE(*S->getSE()) {}
SCEVAffinator::~SCEVAffinator() {
- for (const auto &CachedPair : CachedExpressions) {
+ for (const auto &CachedPair : CachedExpressions)
isl_pw_aff_free(CachedPair.second);
- isl_set_free(CachedPair.first.second);
- }
}
__isl_give isl_pw_aff *SCEVAffinator::getPwAff(const SCEV *Expr,
- isl_set *Domain) {
- this->Domain = Domain;
+ BasicBlock *BB) {
+ this->BB = BB;
- if (Domain)
- NumIterators = isl_set_n_dim(Domain);
- else
+ if (BB) {
+ auto *DC = S->getDomainConditions(BB);
+ NumIterators = isl_set_n_dim(DC);
+ isl_set_free(DC);
+ } else
NumIterators = 0;
S->addParams(getParamsInAffineExpr(&R, Expr, SE));
@@ -52,12 +52,10 @@ __isl_give isl_pw_aff *SCEVAffinator::ge
__isl_give isl_pw_aff *SCEVAffinator::visit(const SCEV *Expr) {
- auto Key = std::make_pair(Expr, isl_set_copy(Domain));
+ auto Key = std::make_pair(Expr, BB);
isl_pw_aff *PWA = CachedExpressions[Key];
- if (PWA) {
- isl_set_free(Domain);
+ if (PWA)
return isl_pw_aff_copy(PWA);
- }
// In case the scev is a valid parameter, we do not further analyze this
// expression, but create a new parameter in the isl_pw_aff. This allows us
More information about the llvm-commits
mailing list