summaryrefslogtreecommitdiffstats
path: root/polly/lib/Analysis/ScopInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib/Analysis/ScopInfo.cpp')
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index ebf1d977605..89696e21e0a 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1416,10 +1416,30 @@ bool Scop::buildAliasGroups(AliasAnalysis &AA) {
return Valid;
}
+static unsigned getMaxLoopDepthInRegion(const Region &R, LoopInfo &LI) {
+ unsigned MinLD = INT_MAX, MaxLD = 0;
+ for (BasicBlock *BB : R.blocks()) {
+ if (Loop *L = LI.getLoopFor(BB)) {
+ unsigned LD = L->getLoopDepth();
+ MinLD = std::min(MinLD, LD);
+ MaxLD = std::max(MaxLD, LD);
+ }
+ }
+
+ // Handle the case that there is no loop in the SCoP first.
+ if (MaxLD == 0)
+ return 1;
+
+ assert(MinLD >= 1 && "Minimal loop depth should be at least one");
+ assert(MaxLD >= MinLD &&
+ "Maximal loop depth was smaller than mininaml loop depth?");
+ return MaxLD - MinLD + 1;
+}
+
Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution,
isl_ctx *Context)
: SE(&ScalarEvolution), R(tempScop.getMaxRegion()),
- MaxLoopDepth(tempScop.getMaxLoopDepth()) {
+ MaxLoopDepth(getMaxLoopDepthInRegion(tempScop.getMaxRegion(), LI)) {
IslCtx = Context;
buildContext();
@@ -1785,7 +1805,7 @@ bool ScopInfo::runOnRegion(Region *R, RGPassManager &RGM) {
// Statistics.
++ScopFound;
- if (tempScop->getMaxLoopDepth() > 0)
+ if (scop->getMaxLoopDepth() > 0)
++RichScopFound;
scop = new Scop(*tempScop, LI, SE, ctx);
OpenPOWER on IntegriCloud