Index: lib/Transforms/Scalar/LoopInterchange.cpp =================================================================== --- lib/Transforms/Scalar/LoopInterchange.cpp +++ lib/Transforms/Scalar/LoopInterchange.cpp @@ -15,6 +15,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringRef.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/DependenceAnalysis.h" @@ -51,6 +52,8 @@ #define DEBUG_TYPE "loop-interchange" +STATISTIC(LoopsInterchanged, "Number of loops interchanged"); + static cl::opt LoopInterchangeCostThreshold( "loop-interchange-threshold", cl::init(0), cl::Hidden, cl::desc("Interchange if you gain more than this number")); @@ -613,6 +616,7 @@ LoopNestExit, LIL.hasInnerLoopReduction()); LIT.transform(); DEBUG(dbgs() << "Loops interchanged.\n"); + LoopsInterchanged++; return true; } }; Index: test/Transforms/LoopInterchange/interchange-no-deps.ll =================================================================== --- test/Transforms/LoopInterchange/interchange-no-deps.ll +++ test/Transforms/LoopInterchange/interchange-no-deps.ll @@ -1,5 +1,6 @@ ; RUN: opt < %s -loop-interchange -simplifycfg -pass-remarks-output=%t \ -; RUN: -pass-remarks=loop-interchange -pass-remarks-missed=loop-interchange -S +; RUN: -pass-remarks=loop-interchange -pass-remarks-missed=loop-interchange -stats -S 2>&1 \ +; RUN: | FileCheck -check-prefix=STATS %s ; RUN: FileCheck -input-file %t %s @@ -87,3 +88,6 @@ exit: ; preds = %for1.inc ret i32 0 } + +; Check stats, we interchanged 1 out of 3 loops. +; STATS: 1 loop-interchange - Number of loops interchanged