diff options
Diffstat (limited to 'polly/lib/Analysis/ScopDetection.cpp')
| -rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 24 |
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 |

