[Committed] [PATCH 3/3] ScopInfo: Rememeber the induction variable and its parent loop at the same thime.

1 view
Skip to first unread message

ether zhhb

unread,
Apr 29, 2011, 11:41:21 PM4/29/11
to polly-commits
---
include/polly/ScopInfo.h | 8 +++++++-
lib/Analysis/ScopInfo.cpp | 13 +++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/include/polly/ScopInfo.h b/include/polly/ScopInfo.h
index 84f404f..4d4666b 100755
--- a/include/polly/ScopInfo.h
+++ b/include/polly/ScopInfo.h
@@ -243,7 +243,7 @@ class ScopStmt {
/// @brief The loop induction variables surrounding the statement.
///
/// This information is only needed for final code generation.
- std::vector<PHINode*> IVS;
+ std::vector<std::pair<PHINode*, Loop*> > IVS;

std::string BaseName;

@@ -321,6 +321,12 @@ public:
/// @return The induction variable at a certain dimension.
const PHINode *getInductionVariableForDimension(unsigned Dimension) const;

+ /// @brief Get the loop for a dimension.
+ ///
+ /// @param Dimension The dimension of the induction variable
+ /// @return The loop at a certain dimension.
+ const Loop *getLoopForDimension(unsigned Dimension) const;
+
/// @brief Return the SCEV for a loop dimension.
const SCEVAddRecExpr *getSCEVForDimension(unsigned Dimension) const;

diff --git a/lib/Analysis/ScopInfo.cpp b/lib/Analysis/ScopInfo.cpp
index 0dfbb92..1cf1930 100644
--- a/lib/Analysis/ScopInfo.cpp
+++ b/lib/Analysis/ScopInfo.cpp
@@ -525,7 +525,7 @@ void
ScopStmt::buildIterationDomainFromLoops(TempScop &tempScop) {
Domain = isl_set_intersect(Domain, isl_set_from_basic_set(bset));

// Upper bound: IV <= NumberOfIterations.
- const Loop *L = getSCEVForDimension(i)->getLoop();
+ const Loop *L = getLoopForDimension(i);
const SCEVAffFunc &UpperBound = tempScop.getLoopBound(L);
isl_set *UpperBoundSet = toUpperLoopBound(UpperBound,
isl_dim_copy(dim), i);
Domain = isl_set_intersect(Domain, UpperBoundSet);
@@ -575,7 +575,7 @@ ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop,
for (unsigned i = 0, e = NestLoops.size(); i < e; ++i) {
PHINode *PN = NestLoops[i]->getCanonicalInductionVariable();
assert(PN && "Non canonical IV in Scop!");
- IVS[i] = PN;
+ IVS[i] = std::make_pair(PN, NestLoops[i]);
}

raw_string_ostream OS(BaseName);
@@ -677,12 +677,17 @@ const char *ScopStmt::getBaseName() const {
return BaseName.c_str(); }

const PHINode *ScopStmt::getInductionVariableForDimension(unsigned Dimension)
const {
- return IVS[Dimension];
+ return IVS[Dimension].first;
+}
+
+const Loop *ScopStmt::getLoopForDimension(unsigned Dimension) const {
+ return IVS[Dimension].second;
}

const SCEVAddRecExpr *ScopStmt::getSCEVForDimension(unsigned Dimension)
const {
- PHINode *PN = IVS[Dimension];
+ PHINode *PN =
+ const_cast<PHINode*>(getInductionVariableForDimension(Dimension));
return cast<SCEVAddRecExpr>(getParent()->getSE()->getSCEV(PN));
}

--
1.7.4

Tobias Grosser

unread,
Apr 30, 2011, 11:43:55 AM4/30/11
to polly-...@googlegroups.com, ether zhhb
Nice.

Tobi

Reply all
Reply to author
Forward
0 new messages