LLVM: lib/Transforms/Scalar/LoopInterchange.cpp File Reference (original) (raw)

Go to the source code of this file.

Functions
STATISTIC (LoopsInterchanged, "Number of loops interchanged")
static void printDepMatrix (CharMatrix &DepMatrix)
static bool populateDependencyMatrix (CharMatrix &DepMatrix, unsigned Level, Loop *L, DependenceInfo *DI, ScalarEvolution *SE, OptimizationRemarkEmitter *ORE)
static void interChangeDependencies (CharMatrix &DepMatrix, unsigned FromIndx, unsigned ToIndx)
static bool isLexicographicallyPositive (std::vector< char > &DV)
static bool isLegalToInterChangeLoops (CharMatrix &DepMatrix, unsigned InnerLoopId, unsigned OuterLoopId)
static void populateWorklist (Loop &L, LoopVector &LoopList)
static bool hasMinimumLoopDepth (SmallVectorImpl< Loop * > &LoopList)
static Value * followLCSSA (Value *SV)
static PHINode * findInnerReductionPhi (Loop *L, Value *V)
static bool areInnerLoopExitPHIsSupported (Loop *InnerL, Loop *OuterL, SmallPtrSetImpl< PHINode * > &Reductions)
static bool areOuterLoopExitPHIsSupported (Loop *OuterLoop, Loop *InnerLoop)
static bool areInnerLoopLatchPHIsSupported (Loop *OuterLoop, Loop *InnerLoop)
static void moveBBContents (BasicBlock *FromBB, Instruction *InsertBefore)
Move all instructions except the terminator from FromBB right before InsertBefore.
static void swapBBContents (BasicBlock *BB1, BasicBlock *BB2)
Swap instructions between BB1 and BB2 but keep terminators intact.
static void updateSuccessor (BranchInst *BI, BasicBlock *OldBB, BasicBlock *NewBB, std::vector< DominatorTree::UpdateType > &DTUpdates, bool MustUpdateOnce=true)
static void moveLCSSAPhis (BasicBlock *InnerExit, BasicBlock *InnerHeader, BasicBlock *InnerLatch, BasicBlock *OuterHeader, BasicBlock *OuterLatch, BasicBlock *OuterExit, Loop *InnerLoop, LoopInfo *LI)
Variables
static cl::opt< int > LoopInterchangeCostThreshold ("loop-interchange-threshold", cl::init(0), cl::Hidden, cl::desc("Interchange if you gain more than this number"))
static cl::opt< unsigned int > MaxMemInstrCount ("loop-interchange-max-meminstr-count", cl::init(64), cl::Hidden, cl::desc("Maximum number of load-store instructions that should be handled " "in the dependency matrix. Higher value may lead to more interchanges " "at the cost of compile-time"))
static const unsigned MaxLoopNestDepth = 10

DEBUG_TYPE

#define DEBUG_TYPE "loop-interchange"

areInnerLoopExitPHIsSupported()

areInnerLoopLatchPHIsSupported()

static bool areInnerLoopLatchPHIsSupported ( Loop * OuterLoop, Loop * InnerLoop ) static

areOuterLoopExitPHIsSupported()

static bool areOuterLoopExitPHIsSupported ( Loop * OuterLoop, Loop * InnerLoop ) static

findInnerReductionPhi()

followLCSSA()

hasMinimumLoopDepth()

interChangeDependencies()

static void interChangeDependencies ( CharMatrix & DepMatrix, unsigned FromIndx, unsigned ToIndx ) static

isLegalToInterChangeLoops()

static bool isLegalToInterChangeLoops ( CharMatrix & DepMatrix, unsigned InnerLoopId, unsigned OuterLoopId ) static

isLexicographicallyPositive()

static bool isLexicographicallyPositive ( std::vector< char > & DV) static

moveBBContents()

moveLCSSAPhis()

Definition at line 1460 of file LoopInterchange.cpp.

References llvm::PHINode::addIncoming(), llvm::all_of(), assert(), followLCSSA(), llvm::BasicBlock::getFirstNonPHI(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::BasicBlock::getParent(), I, llvm::Instruction::insertBefore(), llvm::make_early_inc_range(), P, llvm::BasicBlock::phis(), llvm::predecessors(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::BasicBlock::replacePhiUsesWith(), llvm::PHINode::setIncomingBlock(), and llvm::PHINode::setIncomingValue().

populateDependencyMatrix()

Definition at line 90 of file LoopInterchange.cpp.

References assert(), D, llvm::dbgs(), DEBUG_TYPE, llvm::DependenceInfo::depends(), llvm::OptimizationRemarkEmitter::emit(), llvm::Dependence::DVEntry::EQ, llvm::Dependence::DVEntry::GE, llvm::Dependence::DVEntry::GT, I, II, llvm::StringSet< AllocatorTy >::insert(), llvm::Dependence::DVEntry::LE, LLVM_DEBUG, llvm::Dependence::DVEntry::LT, MaxMemInstrCount, and llvm::SmallVectorTemplateBase< T, bool >::push_back().

populateWorklist()

static void populateWorklist ( Loop & L, LoopVector & LoopList ) static

printDepMatrix()

static void printDepMatrix ( CharMatrix & DepMatrix) static

STATISTIC()

STATISTIC ( LoopsInterchanged ,
"Number of loops interchanged"
)

swapBBContents()

updateSuccessor()

LoopInterchangeCostThreshold

cl::opt< int > LoopInterchangeCostThreshold("loop-interchange-threshold", cl::init(0), cl::Hidden, cl::desc("Interchange if you gain more than this number")) ( "loop-interchange-threshold" , cl::init(0) , cl::Hidden , cl::desc("Interchange if you gain more than this number") ) static

MaxLoopNestDepth

MaxMemInstrCount

cl::opt< unsigned int > MaxMemInstrCount("loop-interchange-max-meminstr-count", cl::init(64), cl::Hidden, cl::desc( "Maximum number of load-store instructions that should be handled " "in the dependency matrix. Higher value may lead to more interchanges " "at the cost of compile-time")) ( "loop-interchange-max-meminstr-count" , cl::init(64) , cl::Hidden , cl::desc( "Maximum number of load-store instructions that should be handled " "in the dependency matrix. Higher value may lead to more interchanges " "at the cost of compile-time") ) static