forked from OSchip/llvm-project
[NFCI][AggressiveInstCombiner] Add `STATISTIC()`s for transforms
This commit is contained in:
parent
43c4afb56f
commit
e987ee6318
|
@ -16,6 +16,7 @@
|
|||
#include "AggressiveInstCombineInternal.h"
|
||||
#include "llvm-c/Initialization.h"
|
||||
#include "llvm-c/Transforms/AggressiveInstCombine.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/BasicAliasAnalysis.h"
|
||||
#include "llvm/Analysis/GlobalsModRef.h"
|
||||
|
@ -28,11 +29,17 @@
|
|||
#include "llvm/InitializePasses.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace PatternMatch;
|
||||
|
||||
#define DEBUG_TYPE "aggressive-instcombine"
|
||||
|
||||
STATISTIC(NumAnyOrAllBitsSet, "Number of any/all-bits-set patterns folded");
|
||||
STATISTIC(NumGuardedRotates,
|
||||
"Number of guarded rotates transformed into funnel shifts");
|
||||
STATISTIC(NumPopCountRecognized, "Number of popcount idioms recognized");
|
||||
|
||||
namespace {
|
||||
/// Contains expression pattern combiner logic.
|
||||
/// This class provides both the logic to combine expression patterns and
|
||||
|
@ -148,6 +155,7 @@ static bool foldGuardedRotateToFunnelShift(Instruction &I) {
|
|||
IRBuilder<> Builder(PhiBB, PhiBB->getFirstInsertionPt());
|
||||
Function *F = Intrinsic::getDeclaration(Phi.getModule(), IID, Phi.getType());
|
||||
Phi.replaceAllUsesWith(Builder.CreateCall(F, {RotSrc, RotSrc, RotAmt}));
|
||||
++NumGuardedRotates;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -248,6 +256,7 @@ static bool foldAnyOrAllBitsSet(Instruction &I) {
|
|||
: Builder.CreateIsNotNull(And);
|
||||
Value *Zext = Builder.CreateZExt(Cmp, I.getType());
|
||||
I.replaceAllUsesWith(Zext);
|
||||
++NumAnyOrAllBitsSet;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -308,6 +317,7 @@ static bool tryToRecognizePopCount(Instruction &I) {
|
|||
Function *Func = Intrinsic::getDeclaration(
|
||||
I.getModule(), Intrinsic::ctpop, I.getType());
|
||||
I.replaceAllUsesWith(Builder.CreateCall(Func, {Root}));
|
||||
++NumPopCountRecognized;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,15 +27,23 @@
|
|||
#include "AggressiveInstCombineInternal.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/ConstantFolding.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "aggressive-instcombine"
|
||||
|
||||
STATISTIC(
|
||||
NumDAGsReduced,
|
||||
"Number of truncations eliminated by reducing bit width of expression DAG");
|
||||
STATISTIC(NumInstrsReduced,
|
||||
"Number of instructions whose bit width was reduced");
|
||||
|
||||
/// Given an instruction and a container, it fills all the relevant operands of
|
||||
/// that instruction, with respect to the Trunc expression dag optimizaton.
|
||||
static void getRelevantOperands(Instruction *I, SmallVectorImpl<Value *> &Ops) {
|
||||
|
@ -303,6 +311,7 @@ Value *TruncInstCombine::getReducedOperand(Value *V, Type *SclTy) {
|
|||
}
|
||||
|
||||
void TruncInstCombine::ReduceExpressionDag(Type *SclTy) {
|
||||
NumInstrsReduced += InstInfoMap.size();
|
||||
for (auto &Itr : InstInfoMap) { // Forward
|
||||
Instruction *I = Itr.first;
|
||||
TruncInstCombine::Info &NodeInfo = Itr.second;
|
||||
|
@ -421,6 +430,7 @@ bool TruncInstCombine::run(Function &F) {
|
|||
"dominated by: "
|
||||
<< CurrentTruncInst << '\n');
|
||||
ReduceExpressionDag(NewDstSclTy);
|
||||
++NumDAGsReduced;
|
||||
MadeIRChange = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue