[PATCH] D20984: add control flags to LICM
Sebastian Pop via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 13:10:47 PDT 2016
sebpop created this revision.
sebpop added reviewers: dberlin, majnemer.
sebpop added a subscriber: llvm-commits.
sebpop set the repository for this revision to rL LLVM.
This patch adds -licm-max-hoist and -licm-max-sink to debug the LICM pass.
Repository:
rL LLVM
http://reviews.llvm.org/D20984
Files:
llvm/lib/Transforms/Scalar/LICM.cpp
Index: llvm/lib/Transforms/Scalar/LICM.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LICM.cpp
+++ llvm/lib/Transforms/Scalar/LICM.cpp
@@ -77,6 +77,16 @@
static cl::opt<bool>
DisablePromotion("disable-licm-promotion", cl::Hidden,
cl::desc("Disable memory promotion in LICM pass"));
+static cl::opt<int>
+ LICMMaxHoist("licm-max-hoist", cl::Hidden, cl::init(-1),
+ cl::desc("Max number of instructions to hoist "
+ "(default unlimited = -1)"));
+static cl::opt<int>
+ LICMMaxSink("licm-max-sink", cl::Hidden, cl::init(-1),
+ cl::desc("Max number of instructions to sink "
+ "(default unlimited = -1)"));
+static int HoistCtr = 0;
+static int SinkCtr = 0;
static bool inSubLoop(BasicBlock *BB, Loop *CurLoop, LoopInfo *LI);
static bool isNotUsedInLoop(const Instruction &I, const Loop *CurLoop,
@@ -628,14 +638,18 @@
static bool sink(Instruction &I, const LoopInfo *LI, const DominatorTree *DT,
const Loop *CurLoop, AliasSetTracker *CurAST,
const LICMSafetyInfo *SafetyInfo) {
+ if (LICMMaxSink != -1) {
+ if (SinkCtr >= LICMMaxSink)
+ return false;
+ ++SinkCtr;
+ }
+
DEBUG(dbgs() << "LICM sinking instruction: " << I << "\n");
- bool Changed = false;
if (isa<LoadInst>(I))
++NumMovedLoads;
else if (isa<CallInst>(I))
++NumMovedCalls;
++NumSunk;
- Changed = true;
#ifndef NDEBUG
SmallVector<BasicBlock *, 32> ExitBlocks;
@@ -688,14 +702,20 @@
CurAST->deleteValue(&I);
I.eraseFromParent();
- return Changed;
+ return true;
}
-/// When an instruction is found to only use loop invariant operands that
-/// is safe to hoist, this instruction is called to do the dirty work.
+/// When an instruction is found to only use loop invariant operands that is
+/// safe to hoist, this function is called to do the dirty work.
///
static bool hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop,
const LICMSafetyInfo *SafetyInfo) {
+ if (LICMMaxHoist != -1) {
+ if (HoistCtr >= LICMMaxHoist)
+ return false;
+ ++HoistCtr;
+ }
+
auto *Preheader = CurLoop->getLoopPreheader();
DEBUG(dbgs() << "LICM hoisting to " << Preheader->getName() << ": " << I
<< "\n");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20984.59607.patch
Type: text/x-patch
Size: 2383 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160603/0f78137c/attachment.bin>
More information about the llvm-commits
mailing list