From e6e3c9246a67025fd25b54b73134da4ebe4a89ff Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Thu, 12 May 2016 20:21:50 +0000 Subject: [PATCH] Check late for profitability Before this patch we only expanded valid __and__ profitable region. Therefor we did not allow the expansion to create a profitable region from a non-profitable one. With this patch we will remember and expand all valid regions and check for profitability only at the end. This patch increases the number of valid SCoPs in the LLVM-TS and SPEC 2000/2006 by 28% (from 303 to 390), including the hot loop in hmmer. llvm-svn: 269343 --- polly/lib/Analysis/ScopDetection.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index fedca6fd2062..52f57d6ec2c1 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -1350,9 +1350,6 @@ bool ScopDetection::isValidRegion(DetectionContext &Context) const { return invalid(Context, /*Assert=*/true, &CurRegion, DbgLoc); - if (!isProfitableRegion(Context)) - return false; - DEBUG(dbgs() << "OK\n"); return true; } @@ -1472,6 +1469,19 @@ bool ScopDetection::runOnFunction(llvm::Function &F) { findScops(*TopRegion); + // Prune non-profitable regions. + for (auto &DIt : DetectionContextMap) { + auto &DC = DIt.getSecond(); + if (DC.Log.hasErrors()) + continue; + if (!ValidRegions.count(&DC.CurRegion)) + continue; + if (isProfitableRegion(DC)) + continue; + + ValidRegions.remove(&DC.CurRegion); + } + // Only makes sense when we tracked errors. if (PollyTrackFailures) emitMissedRemarks(F);