[polly] r256940 - Define buildScheduleRec on RegionNodes and pull out the tree traversal [NFC]
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 6 07:30:07 PST 2016
Author: grosser
Date: Wed Jan 6 09:30:06 2016
New Revision: 256940
URL: http://llvm.org/viewvc/llvm-project?rev=256940&view=rev
Log:
Define buildScheduleRec on RegionNodes and pull out the tree traversal [NFC]
This change clarifies that for Not-NonAffine-SubRegions we actually iterate over
the subnodes and for both NonAffine-SubRegions and BasicBlocks, we perform the
schedule construction. As a result, the tree traversal becomes trivial, the
special case for a scop consisting just of a single non-affine region
disappears and the indentation of the code is reduced.
No functional change intended.
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=256940&r1=256939&r2=256940&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Wed Jan 6 09:30:06 2016
@@ -1408,12 +1408,12 @@ private:
///
void buildSchedule();
- /// @brief Build Schedule for the region @p R.
+ /// @brief Build Schedule for the region @p RN.
///
- /// @param R The current region traversed.
+ /// @param RN The current region traversed.
/// @param LoopSchedules Map from loops to their schedule and progress.
void buildSchedule(
- Region *R,
+ RegionNode *RN,
DenseMap<Loop *, std::pair<isl_schedule *, unsigned>> &LoopSchedules);
/// @brief Collect all memory access relations of a given type.
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=256940&r1=256939&r2=256940&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Jan 6 09:30:06 2016
@@ -3428,84 +3428,71 @@ void Scop::addScopStmt(BasicBlock *BB, R
}
void Scop::buildSchedule() {
-
- // Special case for SCoPs that consist only of one non-affine region.
- if (SD.isNonAffineSubRegion(&getRegion(), &getRegion())) {
- ScopStmt *Stmt = getStmtForBasicBlock(getRegion().getEntry());
- isl_set *Domain = Stmt->getDomain();
- Schedule = isl_schedule_from_domain(isl_union_set_from_set(Domain));
- return;
- }
-
- // For general SCoPs invoke the recursive schedule generation.
DenseMap<Loop *, std::pair<isl_schedule *, unsigned>> LoopSchedules;
Loop *L = getLoopSurroundingRegion(getRegion(), LI);
LoopSchedules[L];
- buildSchedule(&getRegion(), LoopSchedules);
+ buildSchedule(getRegion().getNode(), LoopSchedules);
Schedule = LoopSchedules[L].first;
}
void Scop::buildSchedule(
- Region *R,
+ RegionNode *RN,
DenseMap<Loop *, std::pair<isl_schedule *, unsigned>> &LoopSchedules) {
- ReversePostOrderTraversal<Region *> RTraversal(R);
- for (auto *RN : RTraversal) {
-
- if (RN->isSubRegion()) {
- Region *SubRegion = RN->getNodeAs<Region>();
- if (!SD.isNonAffineSubRegion(SubRegion, &getRegion())) {
- buildSchedule(SubRegion, LoopSchedules);
- continue;
- }
+ if (RN->isSubRegion()) {
+ auto *LocalRegion = RN->getNodeAs<Region>();
+ if (!SD.isNonAffineSubRegion(LocalRegion, &getRegion())) {
+ ReversePostOrderTraversal<Region *> RTraversal(LocalRegion);
+ for (auto *Child : RTraversal)
+ buildSchedule(Child, LoopSchedules);
+ return;
}
+ }
- Loop *L = getRegionNodeLoop(RN, LI);
- if (!getRegion().contains(L))
- L = getLoopSurroundingRegion(getRegion(), LI);
-
- int LD = getRelativeLoopDepth(L);
- auto &LSchedulePair = LoopSchedules[L];
- LSchedulePair.second += getNumBlocksInRegionNode(RN);
-
- ScopStmt *Stmt = getStmtForRegionNode(RN);
- if (Stmt) {
- auto *UDomain = isl_union_set_from_set(Stmt->getDomain());
- auto *StmtSchedule = isl_schedule_from_domain(UDomain);
- LSchedulePair.first =
- combineInSequence(LSchedulePair.first, StmtSchedule);
- }
+ Loop *L = getRegionNodeLoop(RN, LI);
+ if (!getRegion().contains(L))
+ L = getLoopSurroundingRegion(getRegion(), LI);
+
+ int LD = getRelativeLoopDepth(L);
+ auto &LSchedulePair = LoopSchedules[L];
+ LSchedulePair.second += getNumBlocksInRegionNode(RN);
+
+ ScopStmt *Stmt = getStmtForRegionNode(RN);
+ if (Stmt) {
+ auto *UDomain = isl_union_set_from_set(Stmt->getDomain());
+ auto *StmtSchedule = isl_schedule_from_domain(UDomain);
+ LSchedulePair.first = combineInSequence(LSchedulePair.first, StmtSchedule);
+ }
- isl_schedule *LSchedule = LSchedulePair.first;
- unsigned NumVisited = LSchedulePair.second;
- while (L && NumVisited == L->getNumBlocks()) {
- auto *PL = L->getParentLoop();
-
- // Either we have a proper loop and we also build a schedule for the
- // parent loop or we have a infinite loop that does not have a proper
- // parent loop. In the former case this conditional will be skipped, in
- // the latter case however we will break here as we do not build a domain
- // nor a schedule for a infinite loop.
- assert(LoopSchedules.count(PL) || LSchedule == nullptr);
- if (!LoopSchedules.count(PL))
- break;
-
- auto &PSchedulePair = LoopSchedules[PL];
-
- if (LSchedule) {
- auto *LDomain = isl_schedule_get_domain(LSchedule);
- auto *MUPA = mapToDimension(LDomain, LD + 1);
- LSchedule = isl_schedule_insert_partial_schedule(LSchedule, MUPA);
- PSchedulePair.first = combineInSequence(PSchedulePair.first, LSchedule);
- }
-
- PSchedulePair.second += NumVisited;
-
- L = PL;
- LD--;
- NumVisited = PSchedulePair.second;
- LSchedule = PSchedulePair.first;
+ isl_schedule *LSchedule = LSchedulePair.first;
+ unsigned NumVisited = LSchedulePair.second;
+ while (L && NumVisited == L->getNumBlocks()) {
+ auto *PL = L->getParentLoop();
+
+ // Either we have a proper loop and we also build a schedule for the
+ // parent loop or we have a infinite loop that does not have a proper
+ // parent loop. In the former case this conditional will be skipped, in
+ // the latter case however we will break here as we do not build a domain
+ // nor a schedule for a infinite loop.
+ assert(LoopSchedules.count(PL) || LSchedule == nullptr);
+ if (!LoopSchedules.count(PL))
+ break;
+
+ auto &PSchedulePair = LoopSchedules[PL];
+
+ if (LSchedule) {
+ auto *LDomain = isl_schedule_get_domain(LSchedule);
+ auto *MUPA = mapToDimension(LDomain, LD + 1);
+ LSchedule = isl_schedule_insert_partial_schedule(LSchedule, MUPA);
+ PSchedulePair.first = combineInSequence(PSchedulePair.first, LSchedule);
}
+
+ PSchedulePair.second += NumVisited;
+
+ L = PL;
+ LD--;
+ NumVisited = PSchedulePair.second;
+ LSchedule = PSchedulePair.first;
}
}
More information about the llvm-commits
mailing list