[polly] r311469 - [ScopDetection] Add stat for total number of loops.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 22 10:09:51 PDT 2017


Author: meinersbur
Date: Tue Aug 22 10:09:51 2017
New Revision: 311469

URL: http://llvm.org/viewvc/llvm-project?rev=311469&view=rev
Log:
[ScopDetection] Add stat for total number of loops.

The total number of loops is useful as a baseline comparing how many
loops have been optimized in different configurations.

Modified:
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/test/ScopDetect/statistics.ll

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=311469&r1=311468&r2=311469&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Tue Aug 22 10:09:51 2017
@@ -212,6 +212,8 @@ StringRef polly::PollySkipFnAttr = "poll
 //===----------------------------------------------------------------------===//
 // Statistics.
 
+STATISTIC(NumTotalLoops, "Number of loops (in- or out of scops, in any "
+                         "function processed by Polly)");
 STATISTIC(NumScopRegions, "Number of scops");
 STATISTIC(NumLoopsInScop, "Number of loops in scops");
 STATISTIC(NumScopsDepthOne, "Number of scops with maximal loop depth 1");
@@ -303,6 +305,17 @@ static bool doesStringMatchAnyRegex(Stri
 //===----------------------------------------------------------------------===//
 // ScopDetection.
 
+static void countTotalLoops(Loop *L) {
+  NumTotalLoops++;
+  for (Loop *SubLoop : L->getSubLoops())
+    countTotalLoops(SubLoop);
+}
+
+static void countTotalLoops(LoopInfo &LI) {
+  for (Loop *L : LI)
+    countTotalLoops(L);
+}
+
 ScopDetection::ScopDetection(Function &F, const DominatorTree &DT,
                              ScalarEvolution &SE, LoopInfo &LI, RegionInfo &RI,
                              AliasAnalysis &AA, OptimizationRemarkEmitter &ORE)
@@ -325,6 +338,7 @@ ScopDetection::ScopDetection(Function &F
 
   findScops(*TopRegion);
 
+  countTotalLoops(LI);
   NumScopRegions += ValidRegions.size();
 
   // Prune non-profitable regions.

Modified: polly/trunk/test/ScopDetect/statistics.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopDetect/statistics.ll?rev=311469&r1=311468&r2=311469&view=diff
==============================================================================
--- polly/trunk/test/ScopDetect/statistics.ll (original)
+++ polly/trunk/test/ScopDetect/statistics.ll Tue Aug 22 10:09:51 2017
@@ -2,6 +2,7 @@
 
 ; REQUIRES: asserts
 
+; CHECK-DAG: 10 polly-detect     - Number of loops (in- or out of scops, in any function processed by Polly)
 ; CHECK-DAG:  4 polly-detect     - Maximal number of loops in scops (profitable scops only)
 ; CHECK-DAG:  4 polly-detect     - Maximal number of loops in scops
 ; CHECK-DAG: 10 polly-detect     - Number of loops in scops (profitable scops only)




More information about the llvm-commits mailing list