LLVM  4.0.0
Macros | Functions | Variables
LoopUnroll.cpp File Reference
#include "llvm/Transforms/Utils/UnrollLoop.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/LoopIterator.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/OptimizationDiagnosticInfo.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopSimplify.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/SimplifyIndVar.h"
Include dependency graph for LoopUnroll.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "loop-unroll"
 

Functions

 STATISTIC (NumCompletelyUnrolled,"Number of loops completely unrolled")
 
 STATISTIC (NumUnrolled,"Number of loops unrolled (completely or otherwise)")
 
static void remapInstruction (Instruction *I, ValueToValueMapTy &VMap)
 Convert the instruction operands from referencing the current values into those specified by VMap. More...
 
static BasicBlockfoldBlockIntoPredecessor (BasicBlock *BB, LoopInfo *LI, ScalarEvolution *SE, SmallPtrSetImpl< Loop * > &ForgottenLoops, DominatorTree *DT)
 Folds a basic block into its predecessor if it only has one predecessor, and that predecessor only has one successor. More...
 
static bool needToInsertPhisForLCSSA (Loop *L, std::vector< BasicBlock * > Blocks, LoopInfo *LI)
 Check if unrolling created a situation where we need to insert phi nodes to preserve LCSSA form. More...
 

Variables

static cl::opt< boolUnrollRuntimeEpilog ("unroll-runtime-epilog", cl::init(false), cl::Hidden, cl::desc("Allow runtime unrolled loops to be unrolled ""with epilog instead of prolog."))
 

Macro Definition Documentation

#define DEBUG_TYPE   "loop-unroll"

Definition at line 43 of file LoopUnroll.cpp.

Referenced by llvm::UnrollLoop().

Function Documentation

static BasicBlock* foldBlockIntoPredecessor ( BasicBlock BB,
LoopInfo LI,
ScalarEvolution SE,
SmallPtrSetImpl< Loop * > &  ForgottenLoops,
DominatorTree DT 
)
static

Folds a basic block into its predecessor if it only has one predecessor, and that predecessor only has one successor.

The LoopInfo Analysis that is passed will be kept consistent. If folding is successful references to the containing loop must be removed from ScalarEvolution by calling ScalarEvolution::forgetLoop because SE may have references to the eliminated BB. The argument ForgottenLoops contains a set of loops that have already been forgotten to prevent redundant, expensive calls to ScalarEvolution::forgetLoop. Returns the new combined block.

Definition at line 83 of file LoopUnroll.cpp.

References llvm::DominatorTreeBase< N >::changeImmediateDominator(), llvm::dbgs(), DEBUG, llvm::StringRef::empty(), llvm::BasicBlock::end(), llvm::BasicBlock::eraseFromParent(), llvm::DominatorTreeBase< N >::eraseNode(), llvm::FoldSingleEntryPHINodes(), llvm::ScalarEvolution::forgetLoop(), llvm::BasicBlock::getInstList(), llvm::LoopInfoBase< N, M >::getLoopFor(), llvm::Value::getName(), llvm::DominatorTreeBase< N >::getNode(), llvm::TerminatorInst::getNumSuccessors(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getTerminator(), llvm::Value::hasName(), llvm::SmallPtrSetImpl< PtrType >::insert(), L, llvm::iplist_impl< IntrusiveListT, TraitsT >::pop_back(), llvm::LoopInfoBase< N, M >::removeBlock(), llvm::Value::replaceAllUsesWith(), llvm::Value::setName(), and llvm::iplist_impl< IntrusiveListT, TraitsT >::splice().

Referenced by llvm::UnrollLoop().

static bool needToInsertPhisForLCSSA ( Loop L,
std::vector< BasicBlock * >  Blocks,
LoopInfo LI 
)
static

Check if unrolling created a situation where we need to insert phi nodes to preserve LCSSA form.

Parameters
Blocksis a vector of basic blocks representing unrolled loop.
Lis the outer loop. It's possible that some of the blocks are in L, and some are not. In this case, if there is a use is outside L, and definition is inside L, we need to insert a phi-node, otherwise LCSSA will be broken. The function is just a helper function for llvm::UnrollLoop that returns true if this situation occurs, indicating that LCSSA needs to be fixed.

Definition at line 155 of file LoopUnroll.cpp.

References llvm::LoopBase< N, M >::contains(), llvm::tgtok::Def, llvm::LoopInfoBase< N, M >::getLoopFor(), I, and L.

Referenced by llvm::UnrollLoop().

static void remapInstruction ( Instruction I,
ValueToValueMapTy VMap 
)
inlinestatic
STATISTIC ( NumCompletelyUnrolled  ,
"Number of loops completely unrolled"   
)
STATISTIC ( NumUnrolled  ,
"Number of loops unrolled (completely or otherwise)"   
)

Variable Documentation

cl::opt<bool> UnrollRuntimeEpilog("unroll-runtime-epilog", cl::init(false), cl::Hidden, cl::desc("Allow runtime unrolled loops to be unrolled ""with epilog instead of prolog."))
static

Referenced by llvm::UnrollLoop().