From 6e0043365b0d902d597ee8611e2acec21966b4b7 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 5 Apr 2018 10:39:23 +0000 Subject: [PATCH] [LoopInterchange] Add stats counter for number of interchanged loops. Reviewers: samparker, karthikthecool, blitz.opensource Reviewed By: samparker Differential Revision: https://reviews.llvm.org/D45209 llvm-svn: 329269 --- llvm/lib/Transforms/Scalar/LoopInterchange.cpp | 4 ++++ llvm/test/Transforms/LoopInterchange/call-instructions.ll | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp index 2455ff2..cab6acc 100644 --- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp +++ b/llvm/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 @@ using namespace llvm; #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")); @@ -616,6 +619,7 @@ struct LoopInterchange : public FunctionPass { LoopNestExit, LIL.hasInnerLoopReduction()); LIT.transform(); DEBUG(dbgs() << "Loops interchanged.\n"); + LoopsInterchanged++; return true; } }; diff --git a/llvm/test/Transforms/LoopInterchange/call-instructions.ll b/llvm/test/Transforms/LoopInterchange/call-instructions.ll index 27182de..f8b8749 100644 --- a/llvm/test/Transforms/LoopInterchange/call-instructions.ll +++ b/llvm/test/Transforms/LoopInterchange/call-instructions.ll @@ -1,4 +1,5 @@ -; RUN: opt < %s -basicaa -loop-interchange -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t -verify-loop-info -verify-dom-info +; RUN: opt < %s -basicaa -loop-interchange -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t -S \ +; RUN: -stats 2>&1 | FileCheck -check-prefix=STATS %s ; RUN: FileCheck --input-file=%t %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" @@ -113,3 +114,6 @@ for1.loopexit: exit: ret void } + +; Check stats, we interchanged 1 out of 2 loops. +; STATS: 1 loop-interchange - Number of loops interchanged -- 2.7.4