summaryrefslogtreecommitdiffstats
path: root/polly/lib/Analysis/ScopDetection.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <doerfert@cs.uni-saarland.de>2016-05-10 14:42:30 +0000
committerJohannes Doerfert <doerfert@cs.uni-saarland.de>2016-05-10 14:42:30 +0000
commitbf9473b2d8dfeaebcfa25370d16a0f753afa57f8 (patch)
treeee32fe3225605fade3471f763384b0a34e5f88f6 /polly/lib/Analysis/ScopDetection.cpp
parenta31994b7b0fe580ae37d75bfed0f85f087bc48cc (diff)
downloadbcm5719-llvm-bf9473b2d8dfeaebcfa25370d16a0f753afa57f8.tar.gz
bcm5719-llvm-bf9473b2d8dfeaebcfa25370d16a0f753afa57f8.zip
Weaken profitability constraints during ScopDetection
Regions with one affine loop can be profitable if the loop is distributable. To this end we will allow them to be treated as profitable if they contain at least two non-trivial basic blocks. llvm-svn: 269064
Diffstat (limited to 'polly/lib/Analysis/ScopDetection.cpp')
-rw-r--r--polly/lib/Analysis/ScopDetection.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 4ee92fcfa93..34f439bae0b 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -1269,6 +1269,26 @@ bool ScopDetection::hasSufficientCompute(DetectionContext &Context,
return InstCount >= ProfitabilityMinPerLoopInstructions;
}
+bool ScopDetection::hasPossiblyDistributableLoop(
+ DetectionContext &Context) const {
+ for (auto *BB : Context.CurRegion.blocks()) {
+ auto *L = LI->getLoopFor(BB);
+ if (!Context.CurRegion.contains(L))
+ continue;
+ if (Context.BoxedLoopsSet.count(L))
+ continue;
+ unsigned StmtsWithStoresInLoops = 0;
+ for (auto *LBB : L->blocks()) {
+ bool MemStore = false;
+ for (auto &I : *LBB)
+ MemStore |= isa<StoreInst>(&I);
+ StmtsWithStoresInLoops += MemStore;
+ }
+ return (StmtsWithStoresInLoops > 1);
+ }
+ return false;
+}
+
bool ScopDetection::isProfitableRegion(DetectionContext &Context) const {
Region &CurRegion = Context.CurRegion;
@@ -1288,6 +1308,10 @@ bool ScopDetection::isProfitableRegion(DetectionContext &Context) const {
if (NumAffineLoops >= 2)
return true;
+ // A loop with multiple non-trivial blocks migt be amendable to distribution.
+ if (NumAffineLoops == 1 && hasPossiblyDistributableLoop(Context))
+ return true;
+
// Scops that contain a loop with a non-trivial amount of computation per
// loop-iteration are interesting as we may be able to parallelize such
// loops. Individual loops that have only a small amount of computation
OpenPOWER on IntegriCloud