diff options
| author | Tobias Grosser <tobias@grosser.es> | 2015-12-21 12:14:48 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2015-12-21 12:14:48 +0000 |
| commit | 97fc5bb7f7dd31ce77a59dfc3e610d87b070d594 (patch) | |
| tree | 035d302fe296203a1f1d2dcb4910724d39da5bc9 /polly/lib/Analysis/ScopDetection.cpp | |
| parent | 0bfdeb4b6dee9df4f165a2524c0fa8588a28e9f8 (diff) | |
| download | bcm5719-llvm-97fc5bb7f7dd31ce77a59dfc3e610d87b070d594.tar.gz bcm5719-llvm-97fc5bb7f7dd31ce77a59dfc3e610d87b070d594.zip | |
ScopDetect: Extract profitability check into subfunction
.. and add some documentation. We also simplify the code by dropping an early
check that is also covered by the the later checks. This might have a small
compile time impact, but as the scops that are skipped are small we should
probably only add this back in the unlikely case that this has a notable
compile-time cost.
No functional change intended.
llvm-svn: 256149
Diffstat (limited to 'polly/lib/Analysis/ScopDetection.cpp')
| -rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 2c69ca3a659..759d3cb4f55 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -1134,6 +1134,26 @@ bool ScopDetection::allBlocksValid(DetectionContext &Context) const { return true; } +bool ScopDetection::isProfitableRegion(DetectionContext &Context) const { + Region &CurRegion = Context.CurRegion; + + if (PollyProcessUnprofitable) + return true; + + // We can probably not do a lot on scops that only write or only read + // data. + if (!Context.hasStores || !Context.hasLoads) + return invalid<ReportUnprofitable>(Context, /*Assert=*/true, &CurRegion); + + // Check if there are sufficent non-overapproximated loops. + int NumLoops = countBeneficialLoops(&CurRegion); + int NumAffineLoops = NumLoops - Context.BoxedLoopsSet.size(); + if (NumAffineLoops < 2) + return invalid<ReportUnprofitable>(Context, /*Assert=*/true, &CurRegion); + + return true; +} + bool ScopDetection::isValidRegion(DetectionContext &Context) const { Region &CurRegion = Context.CurRegion; @@ -1158,22 +1178,11 @@ bool ScopDetection::isValidRegion(DetectionContext &Context) const { &(CurRegion.getEntry()->getParent()->getEntryBlock())) return invalid<ReportEntry>(Context, /*Assert=*/true, CurRegion.getEntry()); - int NumLoops = countBeneficialLoops(&CurRegion); - if (!PollyProcessUnprofitable && NumLoops < 2) - return invalid<ReportUnprofitable>(Context, /*Assert=*/true, &CurRegion); - if (!allBlocksValid(Context)) return false; - // We can probably not do a lot on scops that only write or only read - // data. - if (!PollyProcessUnprofitable && (!Context.hasStores || !Context.hasLoads)) - return invalid<ReportUnprofitable>(Context, /*Assert=*/true, &CurRegion); - - // Check if there are sufficent non-overapproximated loops. - int NumAffineLoops = NumLoops - Context.BoxedLoopsSet.size(); - if (!PollyProcessUnprofitable && NumAffineLoops < 2) - return invalid<ReportUnprofitable>(Context, /*Assert=*/true, &CurRegion); + if (!isProfitableRegion(Context)) + return false; DEBUG(dbgs() << "OK\n"); return true; |

