[LoopPredication] add some simple stats

Just adding some useful statistics to LoopPredication pass
which was lacking any of these.

llvm-svn: 344681
This commit is contained in:
Fedor Sergeev 2018-10-17 09:02:54 +00:00
parent c014d863be
commit c297e84b97
1 changed files with 8 additions and 0 deletions

View File

@ -178,6 +178,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Scalar/LoopPredication.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
@ -196,6 +197,9 @@
#define DEBUG_TYPE "loop-predication"
STATISTIC(TotalConsidered, "Number of guards considered");
STATISTIC(TotalWidened, "Number of checks widened");
using namespace llvm;
static cl::opt<bool> EnableIVTruncation("loop-predication-enable-iv-truncation",
@ -574,6 +578,8 @@ bool LoopPredication::widenGuardConditions(IntrinsicInst *Guard,
LLVM_DEBUG(dbgs() << "Processing guard:\n");
LLVM_DEBUG(Guard->dump());
TotalConsidered++;
IRBuilder<> Builder(cast<Instruction>(Preheader->getTerminator()));
// The guard condition is expected to be in form of:
@ -615,6 +621,8 @@ bool LoopPredication::widenGuardConditions(IntrinsicInst *Guard,
if (NumWidened == 0)
return false;
TotalWidened += NumWidened;
// Emit the new guard condition
Builder.SetInsertPoint(Guard);
Value *LastCheck = nullptr;