LLVM  8.0.1
Macros | Functions | Variables
LoopUnroll.cpp File Reference
#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/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfoMetadata.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/LoopSimplify.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/SimplifyIndVar.h"
#include "llvm/Transforms/Utils/UnrollLoop.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 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...
 
static bool isEpilogProfitable (Loop *L)
 The function chooses which type of unroll (epilog or prolog) is more profitabale. 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."))
 
static cl::opt< boolUnrollVerifyDomtree ("unroll-verify-domtree", cl::Hidden, cl::desc("Verify domtree after unrolling"), cl::init(false))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-unroll"

Definition at line 43 of file LoopUnroll.cpp.

Referenced by llvm::UnrollLoop().

Function Documentation

◆ isEpilogProfitable()

static bool isEpilogProfitable ( Loop L)
static

The function chooses which type of unroll (epilog or prolog) is more profitabale.

Epilog unroll is more profitable when there is PHI that starts from constant. In this case epilog will leave PHI start from constant, but prolog will convert it to non-constant.

loop: PN = PHI [I, Latch], [CI, PreHeader] I = foo(PN) ...

Epilog unroll case. loop: PN = PHI [I2, Latch], [CI, PreHeader] I1 = foo(PN) I2 = foo(I1) ... Prolog unroll case. NewPN = PHI [PrologI, Prolog], [CI, PreHeader] loop: PN = PHI [I2, Latch], [NewPN, PreHeader] I1 = foo(PN) I2 = foo(I1) ...

Definition at line 244 of file LoopUnroll.cpp.

References assert(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), and llvm::BasicBlock::phis().

Referenced by llvm::UnrollLoop().

◆ needToInsertPhisForLCSSA()

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 166 of file LoopUnroll.cpp.

References llvm::LoopBase< BlockT, LoopT >::contains(), llvm::tgtok::Def, llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), and I.

Referenced by llvm::UnrollLoop().

◆ STATISTIC() [1/2]

STATISTIC ( NumCompletelyUnrolled  ,
"Number of loops completely unrolled"   
)

◆ STATISTIC() [2/2]

STATISTIC ( NumUnrolled  ,
"Number of loops unrolled (completely or otherwise)"   
)

Variable Documentation

◆ UnrollRuntimeEpilog

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().

◆ UnrollVerifyDomtree

cl::opt<bool> UnrollVerifyDomtree("unroll-verify-domtree", cl::Hidden, cl::desc("Verify domtree after unrolling"), cl::init(false))
static

Referenced by llvm::UnrollLoop().